Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Refer to the given program below, what will be the output if the following data is supplied:if variable choice = 2, and in case

1) Refer to the given program below, what will be the output if the following data is supplied:if variable choice = 2, and in case 2 upon calling

function Q31(), before the first for loop the random value generated for x = 85 and y = 54,and before the second loop the random value

generated for x = 48 and y = 4. (10 BLANKS FOR ANSWER INPUT)

#include

#include

#include

#include

using namespace std;

void Q31(char &output);

void Q31();

void Q32();

void Q32(char &output);

int num, ctr;

char output;

int main()

{ int choice; char retry; do { cout << "~~~~~~~~~~~~~~~~M E N U~~~~~~~~~~~~~~~~" << endl

<< "Press 1 for Function 1" << endl

<< "Press 2 for Function 2" << endl

<< "Press 3 for Function 3" << endl

<< "Press 4 for Function 4" << endl << endl

<< "Enter your choice : ";

cin >> choice;

srand(time (0));

switch (choice)

{ case 1:output = rand () % 10 + 65;//will generate letter 65 = 'A'to74 = 'J'

Q31(output);

break;

case 2:Q31();

break;

case 3:Q32();

break;

case 4:output = rand () % 10 + 65;//will generate letter 65 = 'A'to74 = 'J'

Q32(output);

break;

default: cout << choice << " is an INVALID choice value!" << endl;

}

cout << endl << endl;

cout << "Press any KEY to try again or X/x to exit. ";

cin >> retry;

retry = toupper(retry);

cout << endl << endl;

} while (retry != 'X');

return 0;

}

void Q31(char &output)

{

}

void Q31()

{ int x, y;

srand (time(0));

x = rand () % 10 + 80; //will generate number from 80 to 89

y = rand () % 10 + 50;//will generate number from 50 to 59

for (ctr = 1, x = x, y = y; ctr <= 3; x -= y, y -= x, ctr++) //first for loop

{ cout << x << endl << y << endl;

}

x = rand () % 10 + 40; //will generate number from 40 to 49

y = rand () % 10;//will generate number from 0 to 9

for (ctr = 1, x = x, y = y; ctr <= 4; x -= y, y--, ctr++) // second for loop

{ cout << x << endl;

}

}

void Q32()

{

}

void Q32(char &output)

{

}

ANSWER:

2) Refer to the given program below, what will be the output if the following data is supplied:if variable choice = 1, and the variable output has a

random value generated = 'G', calling function Q31(output) in case 1. (5 BLANKS FORANSWER INPUT)

#include

#include

#include

#include

using namespace std;

void Q31(char &output);

void Q31();

void Q32();

void Q32(char &output);

int num, ctr;

char output;

int main()

{ int choice; char retry; do { cout << "~~~~~~~~~~~~~~~~M E N U~~~~~~~~~~~~~~~~" << endl

<< "Press 1 for Function 1" << endl

<< "Press 2 for Function 2" << endl

<< "Press 3 for Function 3" << endl

<< "Press 4 for Function 4" << endl << endl

<< "Enter your choice : ";

cin >> choice;

srand(time (0));

switch (choice)

{ case 1:output = rand () % 10 + 65;//will generate letter 65 = 'A'to74 = 'J'

Q31(output);

break;

case 2:Q31();

break;

case 3:Q32();

break;

case 4:output = rand () % 10 + 65;//will generate letter 65 = 'A'to74 = 'J'

Q32(output);

break;

default: cout << choice << " is an INVALID choice value!" << endl;

}

cout << endl << endl;

cout << "Press any KEY to try again or X/x to exit. ";

cin >> retry;

retry = toupper(retry);

cout << endl << endl;

} while (retry != 'X');

return 0;

}

void Q31(char &output)

{ for (ctr = 1; ctr <= 5; ctr += 1)

{ cout << output << "\t";

output += ctr;

}

}

void Q31()

{

}

void Q32()

{

}

void Q32(char &output)

{

}

ANSWER:

3) Refer to the given program below, what will be the output if the following data is supplied:if variable choice = 3, and the variable num has a

random value generated = 4, calling function Q32() in case 3.

Describe what figure is generated __________.

#include

#include

#include

#include

using namespace std;

void Q31(char &output);

void Q31();

void Q32();

void Q32(char &output);

int num, ctr;

char output;

int main()

{ int choice; char retry; do { cout << "~~~~~~~~~~~~~~~~M E N U~~~~~~~~~~~~~~~~" << endl

<< "Press 1 for Function 1" << endl

<< "Press 2 for Function 2" << endl

<< "Press 3 for Function 3" << endl

<< "Press 4 for Function 4" << endl << endl

<< "Enter your choice : ";

cin >> choice;

srand(time (0));

switch (choice)

{ case 1:output = rand () % 10 + 65;//will generate letter 65 = 'A'to74 = 'J'

Q31(output);

break;

case 2:Q31();

break;

case 3:Q32();

break;

case 4:output = rand () % 10 + 65;//will generate letter 65 = 'A'to74 = 'J'

Q32(output);

break;

default: cout << choice << " is an INVALID choice value!" << endl;

}

cout << endl << endl;

cout << "Press any KEY to try again or X/x to exit. ";

cin >> retry;

retry = toupper(retry);

cout << endl << endl;

} while (retry != 'X');

return 0;

}

void Q31(char &output)

{

}

void Q31()

{

}

void Q32()

{ int row, col;

num = (rand() % 3 + 1) * 2;// will generate number from 2, 4, or 6

for (row = 1; row <= num; row++)

{ for (col = 1; col <= num; col++)

{ if (row <= col)

cout << "*";

else

cout << " ";

}

cout << endl;

}

}

void Q32(char &output)

{

}

ANSWER:

4) Refer to the given program below, what will be the output if the following data is supplied:

if variable choice = 4, and the variable output has a random value generated = 'I', calling function Q32(output) in case 4. (5 BLANKS FOR

ANSWER INPUT)

#include

#include

#include

#include

using namespace std;

void Q31(char &output);

void Q31();

void Q32();

void Q32(char &output);

int num, ctr;

char output;

int main()

{ int choice; char retry; do { cout << "~~~~~~~~~~~~~~~~M E N U~~~~~~~~~~~~~~~~" << endl

<< "Press 1 for Function 1" << endl

<< "Press 2 for Function 2" << endl

<< "Press 3 for Function 3" << endl

<< "Press 4 for Function 4" << endl << endl

<< "Enter your choice : ";

cin >> choice;

srand(time (0));

switch (choice)

{ case 1:output = rand () % 10 + 65;//will generate letter 65 = 'A'to74 = 'J'

Q31(output);

break;

case 2:Q31();

break;

case 3:Q32();

break;

case 4:output = rand () % 10 + 65;//will generate letter 65 = 'A'to74 = 'J'

Q32(output);

break;

default: cout << choice << " is an INVALID choice value!" << endl;

}

cout << endl << endl;

cout << "Press any KEY to try again or X/x to exit. ";

cin >> retry;

retry = toupper(retry);

cout << endl << endl;

} while (retry != 'X');

return 0;

}

void Q31(char &output)

{

}

void Q31()

{

}

void Q32()

{

}

void Q32(char &output)

{num = 5;

for (char outputV = output, ctr = num; ctr >= 1; ctr--)

{ cout << outputV << "\t";

outputV += ctr;

}

}

ANSWER:

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

Students also viewed these Programming questions