Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

QUESTION 3: (10) Draw variable diagrams for the following program with input values 2 (for variable first) and 3 (for variable second). Note : Refer

QUESTION 3:

(10)

Draw variable diagrams for the following program with input values 2 (for variable first) and 3 (for variable second).

Note : Refer to Lesson 23 of the Study Guide and go through the activities to figure out how the execution flows in a program like this where the main() calls other functions. Follow the conventions specified in the Study Guide when you draw the variable diagrams.

For instance:

A ? shows an uninitialized value for a variable.

The notation 25 5 means that execution jumps from line 25 to line 5.

We use square brackets [ ] around the name of a variable to show that it is inaccessible while the current function is being executed.

#include

using namespace std;

3

void multiplyBy2(int firstP, int secondP)

{

firstP = firstP * 2;

secondP = secondP * 2;

}

9

void multiplyBy3(int & firstP, int & secondP)

{

12

firstP = firstP * 3;

secondP = secondP * 3;

}

16

int main()

{

int first, second;

cout << "Enter the first number: "<< endl;

cin >> first;

cout << "Enter the second number:" << endl;

cin >> second;

multiplyBy2(first, second); 25 multiplyBy3(first, second);

cout << "The first number is "<< first << " now." << endl;

cout << "The second number is " << second << " now." << endl;

28

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Q.No.1 Explain Large scale map ? Q.No.2 Explain small scale map ?

Answered: 1 week ago

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago