Question: Write a program in C!! that reads multiple integers from the user and finds the two largest values. The program ignores negative values and prints

Write a program in C!! that reads multiple integers from the user and finds the two largest values. The program ignores negative values and prints amessage indicating so. The sentinel is -1. If the largestvalueor the second largest valueoccurmultiple times, they are countedcounted once, as in the sample below. If no valid input was entered, or only one valid input was entered,the program should print a message indicating so. Use a flag variable that could be (0, 1, 2) to indicate that no input was entered so far, one valid input was entered so far, or two or more valid input were entered so far.

Write a program in C!! that reads multiple integers from the user

Enter integer: 3 Enter integer: -12 >>> Invalid input! Enter integer: 40 Enter integer: 12 Enter integer: 40 Enter integer: 30 Enter integer: -1 The two largest values are: 30 and 40. Enter integer: -15 >>> Invalid input! Enter integer: -12 >>> Invalid input! Enter integer: 6 Enter integer: -1 Only one valid value was entered: 6

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!