Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_step3

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

6. Explain the strengths of a dialectical approach.

Answered: 1 week ago

Question

What did they do? What did they say?

Answered: 1 week ago

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago