1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Airida [17]
2 years ago
14

Write two alternate functions specified below, each of which simply triples the variable count defined in main. These two functi

ons are: a. Function tripleByValue that passes a copy of count by value, triples the copy and returns the new value.b. Function tripleByReference that passes count by reference via a reference parameter and triples the original value of count through its alias(i.e. the reference parameter)For example, if count
Computers and Technology
1 answer:
Vedmedyk [2.9K]2 years ago
7 0

Answer:

Following are the code to this question:

#include <iostream>//header file

using namespace std;

int triplebyValue(int count)//defining a method triplebyValue

{

int x=count*3;//defining a variable x that multiply by 3 in the count  

return x;//return value of x

}

void triplebyReference(int& count)//defining a method triplebyReference that hold count variable as a reference in parameter

{

count*=3;//multipling a value 3 in the count variable

}

int main()//main method

{

int count;//defining integer variable

count=triplebyValue(3);//use count to call triplebyValue method

cout<<"After call by value, count= "<<count<<endl;//print count value with message

triplebyReference(count);//calling a method triplebyReference

cout<<"After call by reference, count= "<<count<<endl;//print count value with message

return 0;

}

Output:

After call by value, count= 9

After call by reference, count= 27

Explanation:

In this code two methods "triplebyValue and triplebyReference" are declared, which accepts a count variable as a parameter, and in both multiply the count value by 3 and return its value.

Inside the main method, an integer variable "count" is declared that first calls the "triplebyValue" method and holds its value into count variable and in the next, the method value is a pass in another method that is "triplebyReference", and use print method to print both methods value with a message.

You might be interested in
Write a Dice Game program that generates two random dice values between 1 and 6 for you, and 2 for the computer. You get to roll
charle [14.2K]

Answer:

#include <iostream>

#include <time.h>

#include <string>

using namespace std;

int main(){

srand(time(NULL));

cout<<"Throw dice"<<endl;

int b =0;

int a=0;

a=rand()%6;

b=rand()%6;

for (int i =0;i<1;i++)

{cout<<"dice one: "<<a<<endl;}

for (int i =0;i<1;i++)

{cout<<"dice two: "<<b<<endl;}

if(a>b)

{cout<<"first dice won"<<endl;}

if(b>a)

{cout<<"second dice won"<<endl;}

else{cout<<"they are same"<<endl;

return main();

}

return 0;

}

Explanation:

/*maybe it help you it is almost done*/

6 0
2 years ago
Software development team leaders need blank skills to excel in directing their teams
IrinaK [193]
I mean, this is tricky because there's a lot of skills they'd need - c<span>ommunication, leadership, organisation, confidence etc. Is there a list of answers to choose from?</span>
5 0
3 years ago
Read 2 more answers
Explain how communication has helped to the staff in organization to reach their maximum delivery of service with efficience and
Gwar [14]

Answer:

i don't know

Explanation:

6 0
2 years ago
Janice, who is 15, posts post a picture of herself drinking alcohol and making an obscene gesture on her social network page. wh
mars1129 [50]

answer

A and B

Explanation.

A and B are the answers because this a real life scenario.

it's also can ruin her dreams on going to college to get a degree on what she want's to be and job application on her degree or any kind of job.

8 0
3 years ago
Read 2 more answers
Write a program that calculates and displays the number of minutes in a month. This program does not require any user input, and
dimulka [17.4K]

Answer:

Code to the answer is shown in the explanation section

Explanation:

import java.util.Scanner;

public class Question {

   public static void main(String args[]) {

     Scanner scan = new Scanner(System.in);

     System.out.println("Please enter the days of the month: ");

     int daysOfMonth = scan.nextInt();

     int minuteOfMonth = daysOfMonth * 60 * 24;

     System.out.println(minuteOfMonth);

   }

}

// 60 represents the number of minutes in one hour

// 24 represents the number of hours in a day

4 0
3 years ago
Other questions:
  • Dr. Laos gets a referral for a 6 month old who has become listless and stopped eating lately. Her pediatrician wanted her to be
    15·1 answer
  • What is the purpose of the overload keyword in the ip nat inside source list 1 pool nat_pool overload command?
    8·1 answer
  • Hen using presentation software, what do you do when you "compose a slide"?
    5·1 answer
  • To prevent unauthorized access and use, at a minimum a company should have a written __________ that outlines the activities for
    6·1 answer
  • Given a Fahrenheit value temperatureFahrenheit, write a statement that assigns temperatureCelsius with the equivalent Celsius va
    9·1 answer
  • Elizabeth works for a local restaurant at the end of her shift she read she’s required to write in the time that she arrived in
    14·1 answer
  • As a general rule, the number of bullet points on a slide should not exceed _____. a.2 b.4 c.8 d.10
    9·1 answer
  • The symbol located to the left of a code number that identifies a code description that has been revised is _____.
    12·1 answer
  • How can IT infrastructure be linked to the business strategy of any organization
    9·1 answer
  • Can able to Computer decide its input by itself? How ?​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!