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]
3 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]3 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
In order for you to realize there has been a sensory change, it has to reach the __________ level of processing.
Kryger [21]

Answer: In order for you to realize there has been a sensory change, it has to reach the <u>perceptual</u> level of processing.

6 0
4 years ago
Software that enables you to display and interact with text and other media on the web is a web ________.
a_sh-v [17]
It's a web site or web page
5 0
4 years ago
Explain why regular system cleanup is vital to ensuring the operating system runs efficiently.
Monica [59]
Cleaning up a system helps clear up the space on the drives. It may also clear up processor usage, ram usage if you uninstall programs that automatically started when the system booted. You may also delete some unwanted programs in the process.
6 0
3 years ago
The large structure that supports a spacecraft prior to launch is called the
OlgaM077 [116]
Launch tower

Hope that helps
         

7 0
3 years ago
How to give a brainiest on a question? if you teach me i will give brainiest
kipiarov [429]

Answer:

OK

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • What is the answers please
    10·1 answer
  • What is a zener diode
    8·1 answer
  • The continue statement _________.
    11·1 answer
  • Secops focuses on integrating the need for the development team to provide iterative and rapid improvement to system functionali
    14·1 answer
  • Which function does the Subtotal feature use?
    5·1 answer
  • Which principle suggests that specific single responsibility interfaces are better than one general purpose interface?
    13·1 answer
  • Auditors often make use of computer programs that perform routine processing functions, such as sorting and merging. These progr
    12·1 answer
  • Difference between Hard copy and Soft copy?​
    13·1 answer
  • When the measured activity is outside the baseline parameters in a behavior-based IDPS, it is said to exceed the ____ (the level
    9·1 answer
  • All mortgage companies are willing to loan anyone money regardless of credit scores. True or false?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!