Question: In C Professionally ask the user for two numbers, and then, display a professionally formatted menu to the user with an appropriate title and list

In C

Professionally ask the user for two numbers, and then, display a professionally formatted menu to the user with an appropriate title and list of options; see the output examples below. The options should include the following:

  • Add the two numbers and display the result
  • Subtract the two numbers and display the result
  • Multiply the two numbers and display the result
  • Divide the two numbers and either display the result or an appropriate error message concerning the cannot divide by zero issue
  • Calculate the average of the two numbers and display the result; the above error may also apply for this option
  • Find and display the largest of the two numbers
  • Display if each number is negative, positive, or zero; because we haven't covered loops yet, you will need a set of nested if-elses for each number, so these two stacked sets of nested if-elses will be the only stacked if/if-else constructs you will need
  • Quits without doing anything other than to display a good-bye message

This is my code. what is wrong with it ?

int main() { int num1, num2; char opt; printf("Enter two numbers separated by a space:"); scanf_s("%d", &num1); scanf_s("%d", &num2);

printf(" Enter the your option: "); printf("(A)ddition. (S)ubstraction. (M)ultiplication. (D)ivision. a(V)erage. (L)argest number "); scanf_s("%c", &opt);

switch (opt) { case 'A': printf("Addition is: %d ", num1 + num2); break; case 'S': printf("Substraction is: %d ",num1 - num2); break; case 'M': printf("Multiplication is: %d ", num1 * num2); break; case 'D': if (num2 == 0) { printf("OOps Devide by zero "); } else { printf(" Division is: %d ", num1 / num2); } break;

case 'V': printf("The average is %d ", (num1 + num2) / 2); break; case 'L': if (num1 > num2) { printf("The largest number is %d ", num1); } else { printf("The largest number is %d ", num2); } break;

} return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!