#include<stdio.h>
//method to read options
int options()
{
int c;
printf("Choose from the following options:\n1,2 or
3?\n");
printf("\t1 to print the two highest
numbers\n");
printf("\t2 to print the product of the three
numbers\n");
printf("\t3 to print the division of the second number
by third\n");
printf("Enter your selection:");
while(1)
{
scanf("%d",&c);
if(c==1||c==2||c==3)return c;
else printf("Sorry Invalid Option!Try again:");
}
}
//asking input
char inner_while_choice(int a,int b,int cc)
{
char c;
printf("Would like to keep working with %d,%d and %d?
Enter y/Y or n/N:",a,b,cc);
while(1)
{
scanf("%c",&c);
scanf("%c",&c);
if(c=='y'||c=='Y')return 'y';
else if(c=='n'||c=='N')return 'n';
else printf("Sorry Invalid entry!Please enter y/Y or
n/N:");
}
}
char outer_while_choice()
{
char c;
printf("Now, would like to work with new numbers?
Enter y/Y or n/N:");
while(1)
{
scanf("%c",&c);
scanf("%c",&c);
if(c=='y'||c=='Y')return 'y';
else if(c=='n'||c=='N')return 'n';
else printf("Sorry Invalid entry!Please enter y/Y or
n/N:");
}
}
int main()
{
int a,b,c;//3 numbers
char cc='y';
int o;
while(cc=='y')
{
printf("Enter the three numbers
:");
scanf("%d %d
%d",&a,&b,&c);//reading numbers
int k='y';
while(k=='y')
{
o=options();
if(o==1)
{
int
max1=a,max2=a;
if(max1<b)
{
max2=max1;
max1=b;
}
if(max1<c)
{
max2=max1;
max1=c;
}
printf("The two
highest numbers are: %d and %d\n",max1,max2);
}
else if(o==2)
{
printf("%d times
%d times %d =%d\n",a,b,c,(a*b*c));
}
else
{
if(c==0)
{
printf("Sorry cannot %d divide by
zero!\n",b);
}
else
{
printf("The division of second number by third
:%f\n",(float)b/c);
}
}
k=inner_while_choice(a,b,c);
}
cc=outer_while_choice();
}
printf("Sad to see you go\n");
return 0;
}
output:
Enter the three numbers :1 10 0
Choose from the following options:
1,2 or 3?
1 to print the two highest numbers
2 to print the product of the three numbers
3 to print the division of the second number by third
Enter your selection:4
Sorry Invalid Option!Try again:3
Sorry cannot 10 divide by zero!
Would like to keep working with 1,10 and 0? Enter y/Y or
n/N:y
Choose from the following options:
1,2 or 3?
1 to print the two highest numbers
2 to print the product of the three numbers
3 to print the division of the second number by third
Enter your selection:2
1 times 10 times 0 =0
Would like to keep working with 1,10 and 0? Enter y/Y or
n/N:1
Sorry Invalid entry!Please enter y/Y or n/N:n
Now, would like to work with new numbers? Enter y/Y or n/N:y
Enter the three numbers :-2 -100 1
Choose from the following options:
1,2 or 3?
1 to print the two highest numbers
2 to print the product of the three numbers
3 to print the division of the second number by third
Enter your selection:1
The two highest numbers are: 1 and -2
Would like to keep working with -2,-100 and 1? Enter y/Y or
n/N:n
Now, would like to work with new numbers? Enter y/Y or n/N:n
Sad to see you go
Process exited normally.
Press any key to continue . . .
//PLS give a thumbs up if you find this helpful, it helps me alot,
thanks.
Write a C program that asks the user to enter three numbers (integres). A menu will...
1. Write a program that asks the user to enter two integers, obtains the numbers from the user, then prints the larger number followed by the words “is larger.” If the numbers are equal, print the message “These numbers are equal.” Use only the single-selection form of the if statement you learned in this chapter.
Write a C program that asks the user to enter two real numbers. Then your program displays a menu that asks the user to choose what arithmetic operation to be done on those numbers. Depending on the user's entry, the program should display the result to the screen. The sample runs below show what should be done to the numbers entered by the user. Your program should run exactly like shown in the sample runs. make your code run as...
Write a program that asks the user to enter number, and displays all the numbers that are multiples of 2 and 5 smaller than or equal to the number entered by the user. Hint: A number n is a multiple of 2 if the remainder of the division of n by 2 is equal to zero. Your program should have an output similar to the following: Please enter a number: 50 The multiples of 2 and 5 less than or...
Write a Program that has a menu with a layout below, that asks the user if they want to: 1. Converts from feet and inches to meter and centimeters 2. Converts from meter and centimeters to feet and inches 3. Quit the program The program should continue as long as the user asks it to. The program will use a switch statement for the menu option selection. Either a do loo or a do-while loop can be used for the overall...
Summary: Write a C program that prompts the user to enter 2 positive integer numbers, display the numbers in 3 formats. Then check, whether the larger of the 2 is evenly divisible by the smaller. Detail: Write a complete C program, more complex than the typical "hello world" program. Prompt the user to enter 2 integer numbers that are not negative. After either entry, display that number again. Print the smaller in hexadecimal, in decimal, and in octal format. Include...
mathTutor Write a program that selects two random numbers -20 to 20. The two numbers would get displayed with "+" between them. The user should enter the sum of the two numbers. The program should print "Incorrect" if the user enters a wrong answer and re-prompts the user to re-enter the answer again. Limit the number of incorrect tries to 3. After 3 incorrect tries print the correct answer. The program should print a message like "Correct!" if the user...
MATLAB QUESTION 8) Create a program that first prompts the user to enter any two numbers. Then prompt the user again to input as many numbers as they choose. Stop the program by inputting-1. Then, display the largest number and second largest number in the command window once the user kills the program. The built-in max function cannot be used. The figure below is an example of what the command window should look like when the code is ran. First...
In C++: Write a program that asks the user for an array of X numbers. Your program moves the largest number all the way to the right, and then shows it to the user. Hint: Use a loop to swap X times, but only swap if the number on the left is bigger than the number on the right. Sample Run: How many numbers would you like to enter? 6 Please enter number 1: 10 Please enter number 2: 8...
mathTutor Write a program that selects two random numbers -20 to 20. The two numbers would get displayed with "+" between them. The user should enter the sum of the two numbers. The program should print "Incorrect" if the user enters a wrong answer and re-prompts the user to re-enter the answer again. Limit the number of incorrect tries to 3. After 3 incorrect tries print the correct answer. The program should print a message like "Correct!" if the user...
Write a program which asks the user to enter an integer. Use switch statement to write out the numeric word (such as ONE) if the user's input is 1; (see the sample run output for the usr input 2 or 3); otherwise, write OUT OF RANGE. Below are few sample runs: If the user enters a 1, the program will print: ONE TWO THREE Or, if the user enters a 2, the program will print: TWO THREE Or, if the...