Asked by Shawn

Read two numbers from the keyboard Display the menu options as follows: 1 - computes the sum of two numbers. 2 - computes the difference (first minus second). 3 - computes the product of the two numbers. 4 - if the second number is not zero, computes the quotient (first divided by second). 5 - terminates the program If the code is not equal to 1,2,3,4 or 5 - displays an error message. The program is then to display the two numbers, the integer code and the computed result to the screen. Use CASE structure in this algorithm.

Answers

Answered by Greg
int a = 10;
int b = 5;
int total = 0;

printf("%d + %d = %d\n", a, b, total);
printf("%d - %d = %d\n", a, b, total);
printf("%d * %d = %d\n", a, b, total);
printf("%d / %d = %d\n", a, b, total);

/*Without an array*/
if(var == 1)
{
return 1;
}
else if(var == 2)
{
return 1;
}
else if(var == 3)
{
return 1;
}
else if(var == 4)
{
return 1;
}
else if(var == 5)
{
return 1;
}
else
{
return 0;
}


I think that is what you want, This is just simple C code. Nothing special.


There are no AI answers yet. The ability to request AI answers is coming soon!

Related Questions