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
Sarah maintains a blog about her soap-making business, and she has hired someone to create a database for this business. She mak
ivann1987 [24]
The database planner would most likely create a table that contains customer contact information since these would be the individuals who placed an order for Sarah's products after visiting her blog. 
4 0
3 years ago
Teenagers and their parents will never understand each other-the generation gap is too big. Its for my grade 11 English speech​
bazaltina [42]

Answer:

lol

Explanation:

lol

7 0
3 years ago
Read 2 more answers
What did major networks do to combat audience erosion in the 1990s?
S_A_V [24]

Answer: I think is 3. They acquired cable channels. They acquired cable operators.

Explanation:

6 0
3 years ago
A(n) ____ describes the structure, content, and access controls of a physical data store or database.
kirill115 [55]

A <u>schema </u>describes the structure, content, and access controls of a physical data store or database.

<h3>What is the kind of database that stores data in a different physical location?</h3>

Distributed databases are that are distributed across several physical locations. In distributed databases, the data are placed where they are used most often, but the whole database is available to each licensed user.

<h3>What is the structure of database management system?</h3>

The database system is separated into three components: Query Processor, Storage Manager, and Disk Storage.

To learn more about Distributed databases, refer

brainly.com/question/28236247

#SPJ4

Complete Question is ,

a. relation

b. DBMS

c. schema

d. attribute

6 0
1 year ago
Show the ERD with relational notation with crowfoot. Drexel University Financial Office has made contracts with several local ba
andreyandreev [35.5K]

Answer:

Detailed ERD Diagram is given in the attachment

3 0
3 years ago
Other questions:
  • Abram was asked to explain to one of his coworkers the XOR cipher. He showed his coworker an example of adding two bits, 1 and 1
    7·1 answer
  • Which key removes all data from an active cell with one click? A. Esc B. Delete C. Tab D. F2
    9·2 answers
  • What does that program print out?<br><br> a) 2<br> b) 3<br> c) 4<br> d) 8
    14·2 answers
  • Which is true about POP3 and IMAP for incoming email?
    10·1 answer
  • How do you reduce computer screen flicker
    11·1 answer
  • The growing network of physical objects that will have sensors connected to the Internet is referred to as the ________.
    13·1 answer
  • The instructions for a computer program are sometimes referred to as . computer programmers focus on computer programs, but they
    5·2 answers
  • What will be result of below if statement.
    13·1 answer
  • Cuantos MB son 8,192 kb?​
    13·1 answer
  • What read a page on website​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!