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
BigorU [14]
3 years ago
8

Given the following function definition:

Computers and Technology
1 answer:
neonofarm [45]3 years ago
4 0

The question is incomplete! Complete question along with its step by step answer is provided below!

Question:

Given the following function definition:

void calc (int a, int& b)

{

int c;

c = a + 2;

a = a * 3;

b = c + a;

}

x = 1;

y = 2;

z = 3;

calc(x, y);

cout << x << " " << y << " " << z << endl;

What is the output of the following code fragment that invokes calc?

a. 1 2 3

b. 1 6 3

c. 3 6 3

d. 1 14 9

e. None of these

Answer:

b. 1 6 3

Explanation:

In the given problem we have a function void calc which takes two input arguments a and b and updates its values according to following equations

c = a + 2;

a = a * 3;

b = c + a;

Then we call this function calc(x,y) by providing test values of

int x = 1;

int y = 2;

int z = 3;

and the output returns the values of x, y and z

cout << x << " " << y << " " << z << endl;

Lets find out what is happening here!

When the program runs we provide x=a=1 and y=b=2

c=a+2=1+2=3

a=a*3=1*3=3

b=c+a=3+3=6

So the updated values of a=x=3 and b=y=6?

NO!

The updated values are a=x=1 and b=y=6

WHY?

There are two ways to pass values

1. Pass by values -> value cannot change  (int a)

2. Pass by reference -> value can change (int& b)

Look at the function void calc (int a, int& b) ;

Here we are passing (int a) as a value and (int& b) as a reference, therefore x remains same x=1 and y gets changed to updated value y=6 and z remains same as z=3 since it wasnt used by function calc(x,y)

The right answer is:

b. 1 6 3

x=1, y=6, z=3

You might be interested in
If byte stuffing is used to transmit Data, what is the byte sequence of the frame (including framing characters)? Format answer
Lerok [7]

Answer:

Correct Answers: 01h 79h 1Bh 78h 78h 1Bh 7Ah 04

Explanation:

Solution is attached below

4 0
3 years ago
Define watcher block
DochEvi [55]

Answer:

Happens when you are watching a series / film / drama / etc. but can not retain the attention span to watch for long periods of time. As well as the shortened viewing time, the ability to retain what has been viewed is impaired.

Explanation:

5 0
3 years ago
Read 2 more answers
What is a raster graphic?
kifflom [539]
<span>In computer graphics, a raster graphics or bitmap image is a dot matrix data structure, representing a generally rectangular grid of pixels, or points of color, viewable via a monitor, paper, or other display medium.</span>
6 0
3 years ago
Explain why the free market system brings efficiency as well as freedom
tangare [24]
The free market system brings efficiency and freedom because it is a system built on buying, selling, and creating. A free market system is open to the public and doesn't have such a rigid structure. It allows anyone with ideas, connections, and opportunities to create and market a potential product. This is efficient in that many people have become entrepreneurs and millionaires while still supplying a valuable product. It brings freedom because it begins with creativity and sometimes authenticity.

Please vote my answer branliest! Thanks.
5 0
3 years ago
someone can help plz " Provide definitions for the following terms: bit, byte, kilobyte (KB), megabyte (MB), gigabyte (GB), Tera
densk [106]

Answer:

Explanation:

Bit: A bit (short for binary digit) is the smallest unit of data in a computer. A bit has a single binary value, either 0 or 1.

Byte: A byte is a data measurement unit that contains eight bits, or a series of eight zeros and ones.

Kilobyte: A KB (kilobyte) is 1000 bytes.

Megatype: An MB (megabyte) is 1000 kilobytes.

Gigatype: A GB (gigabyte) is 1000 megabytes.

Terabyte: A TB (terabyte) is 1000 gigabytes.

hope this helped you!

4 0
3 years ago
Other questions:
  • unittttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
    7·1 answer
  • You recently created several new user accounts in the Sales OU and configured them with the appropriate group membership, logon
    12·1 answer
  • If Nancy receives an encrypted message from Matthew, which key does she use to read it? Nancy’s private key Nancy’s public key M
    8·1 answer
  • Describe an algorithm that, given n integers in range 0 to k, preprocesses its input and then answers any query about how many o
    15·1 answer
  • Jonathan is eight years old and is a participant in a study assessing the eating habits of schoolchildren. To assess the childre
    5·1 answer
  • PLEASE HELP!!!
    12·1 answer
  • What types of storage can be used to access your data on another computer?
    10·2 answers
  • What causes the poles of the electromagnet in an audio speaker to repeatedly switch directions?
    6·2 answers
  • Define data, information and the relation between the two?
    8·1 answer
  • Fill in the missing terms relating to computer software
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!