Respuesta :
Answer:
#include <stdio.h>
print_two_highest(int a, int b, int c){
if(a >= b && a >= c){
if(b >= c) {
printf("%d is the highest number\n", a);
printf("%d is the second highest number\n", b);
}
else {
printf("%d is the highest number\n", a);
printf("%d is the second highest number\n", c);
}
}
else if(b >= a && b >= c){
if(a >= c){
printf("%d is the highest number\n", b);
printf("%d is the second highest number\n",a);
}
else{
printf("%d is the highest number\n", b);
printf("%d is the second highest number\n",c);
}
}
else{
if(a >= b){
printf("%d is the highest number\n", c);
printf("%d is the second highest number\n", a);
}
else{
printf("%d is the highest number\n", c);
printf("%d is the second highest number\n", b);
}
}
}
print_product(int a, int b, int c){
printf("Product of the numbers: %d", a * b * c);
}
print_division_second_by_third(int a, int b, int c) {
if(c != 0)
printf("Division of the second number by the third number: %d", b/c);
}
int main()
{
int number1, number2, number3, option;
printf("Enter three numbers: ");
scanf("%d%d%d", &number1, &number2, &number3);
printf("1-print the two highest numbers \n");
printf("2-print the product of the three numbers \n");
printf("3-print the division of the second by the third if the third is not zero \n");
printf("Choose an option(1 - 2 or 3): ");
scanf("%d", &option);
switch (option) {
case 1:
print_two_highest(number1, number2, number3);
break;
case 2:
print_product(number1, number2, number3);
break;
case 3:
print_division_second_by_third(number1, number2, number3);
break;
default:
printf("Invalid input!");
}
return 0;
}
Explanation:
- Inside the function, find and print the required things
Inside the main:
- Declare the variables
- Ask the user for the numbers
- Ask the user for the menu
- Call the functions depending on the choice of the user