Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include using namespace std; /* run this program using the console pauser or add your own getch, system(pause) or input loop */ int main(int argc,

#include

using namespace std;

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv)

{

int ch,i,a,b,result,guess,chances=0;

Menu:

result=0;

guess=0;

chances=0;

cout <<" 1. Perform a Modulus division of two numbers" <

cout << "2. Perform Multiplication of two numbers" <

cout << "3. Perform Subtraction of two numbers" <

cout << "4. Exit" <

cin>>ch;

switch(ch)

{

case 1: cout << "Enter value for a:";

cin>>a;

cout << " Enter value for b: ";

cin >> b;

result=a%b;

repeat:

cout << "What is the expected output:";

cin >> guess;

if (guess==result)

{

cout << " Congratulation!";

goto Menu;

}

if (guess!=result&&chances!=2)

{

chances++;

goto repeat;

}

else if(chances==2)

{

cout << "The correct answer is:" <

goto Menu;

}

break;

case 2: cout << "Enter value for a :";

cin >>a;

cout << "Enter the value for b: ";

cin >>b;

result=a*b;

repeat2:

cout << "what is the expected output: ";

cin >> guess;

if(guess==result)

{

cout <<"Congratulations!";

goto Menu;

}

if(guess!=result&&chances!=2)

{

chances++;

goto repeat2;

}

else if(chances==2)

{

cout <<"The correct answer is:"<

goto Menu;

}

break;

case 3: cout <<"Enter value is:" <

cin>>a;

cout << "Enter value for b:";

cin >>b;

result=a-b;

if(guess==result)

{

cout <<"Congratulations!";

goto Menu;

}

if(guess!=result&&chances!=2)

{

chances++;

goto repeat2;

}

else if(chances==2)

{

cout <<"The correct answer is: " <

goto Menu;

}

break;

case 4: break;

}

return 0;

}

FLOW CHART FOR THIS CODING

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 Databases questions

Question

Explain competency models and the process used to develop them.

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago