Computer Science, asked by moon8577, 8 months ago

Write a menu driven program using switch...case to do :- Input three numbers and a character value. If the character is 's' then print sum of all three numbers, otherwise if character is 'p', print the product of all these numbers. If the character is neither 's' or 'p' then display a message "invalid input".​​

Answers

Answered by murmutapas224
0

Answer:

int choice, num;

printf("Press 1 to calculate area of circle\n");

printf("Press 2 to calculate area of square\n");

printf("Press 3 to calculate area of sphere\n");

printf("Enter your choice:\n");

choice = input();

switch (choice) {

case 1: {

printf("Enter radius:\n");

num = input();

result = 3.14 * num * num;

printf("Area of sphere=");

output(result);

break;

}

case 2: {

printf("Enter side of square:\n");

num = input();

result = num * num;

printf("Area of square=");

output(result);

break;

}

case 3: {

printf("Enter radius:\n");

num = input();

result = 4 * (3.14 * num * num);

printf("Area of sphere=");

output(result);

break;

}

default:

printf("wrong Input\n");

}

return 0;

}

int input()

{

int number;

scanf("%d", &number);

return (number);

}

void output(float number)

{

printf("%f", number);

}

Similar questions