Write a C program with a loop that asks user to enter a series of integers in th
ID: 3620739 • Letter: W
Question
Write a C program with a loop that asks user to enter a series of integers in the range of [-100 100]. If user enters a number out of that range, your program shouldn’t consider it, and should ask for a new number. The user should enter 0 to stop the loop. When the loop stops, we want your program to display the largest TWO numbers entered in the range of [-100 100], the smallest TWO numbers entered in the range of [-100 100], the average of negative numbers entered in the range of [-100 100], and the average of positive numbers entered in the range of [-100 100].For example if user enters -2, then 3, then -4, then -200, then 5, then -3, then 120, then 0
Your program should stop and print:
Two largest numbers are : 5 3
Two smallest numbers are : -4 -3
Average of negative values is -3
Average of positive values is 4
Explanation / Answer
Write a C program with a loop that asks user to enter a series of integers in the range of [-100 100]. If user enters a number out of that range, your program shouldn’t consider it, and should ask for a new number. Check if the given numbers are within that range. If not, ask the user again.
The user should enter 0 to stop the loop. If the user enters 0, the loop terminates and the printing begins. When the loop stops, we want your program to display the largest TWO numbers entered in the range of [-100 100], Okay, so how are you going to find the largest two numbers? To be sure, you'll need something to store them in, and you'll need to keep track of them as you iterate through your loop.
the smallest TWO numbers entered in the range of [-100 100], Same as above, but check for the opposite condition. the average of negative numbers entered in the range of [-100 100], Similar to the above. Once you have determined whether a number is negative or positive, how are you going to keep track of it? Again, you'll need to store it somewhere. After you do that, I assume you know how to find the average. and the average of positive numbers entered in the range of [-100 100]. Same as above, but check for the opposite condition.
The printing should be trivial if you got the above right.
Write a C program with a loop that asks user to enter a series of integers in the range of [-100 100]. If user enters a number out of that range, your program shouldn’t consider it, and should ask for a new number. Check if the given numbers are within that range. If not, ask the user again.
The user should enter 0 to stop the loop. If the user enters 0, the loop terminates and the printing begins. When the loop stops, we want your program to display the largest TWO numbers entered in the range of [-100 100], Okay, so how are you going to find the largest two numbers? To be sure, you'll need something to store them in, and you'll need to keep track of them as you iterate through your loop.
the smallest TWO numbers entered in the range of [-100 100], Same as above, but check for the opposite condition. the average of negative numbers entered in the range of [-100 100], Similar to the above. Once you have determined whether a number is negative or positive, how are you going to keep track of it? Again, you'll need to store it somewhere. After you do that, I assume you know how to find the average. and the average of positive numbers entered in the range of [-100 100]. Same as above, but check for the opposite condition.
The printing should be trivial if you got the above right.
The user should enter 0 to stop the loop. If the user enters 0, the loop terminates and the printing begins. When the loop stops, we want your program to display the largest TWO numbers entered in the range of [-100 100], Okay, so how are you going to find the largest two numbers? To be sure, you'll need something to store them in, and you'll need to keep track of them as you iterate through your loop.
the smallest TWO numbers entered in the range of [-100 100], Same as above, but check for the opposite condition. the average of negative numbers entered in the range of [-100 100], Similar to the above. Once you have determined whether a number is negative or positive, how are you going to keep track of it? Again, you'll need to store it somewhere. After you do that, I assume you know how to find the average. and the average of positive numbers entered in the range of [-100 100]. Same as above, but check for the opposite condition.
The printing should be trivial if you got the above right.
When the loop stops, we want your program to display the largest TWO numbers entered in the range of [-100 100], Okay, so how are you going to find the largest two numbers? To be sure, you'll need something to store them in, and you'll need to keep track of them as you iterate through your loop.
the smallest TWO numbers entered in the range of [-100 100], the smallest TWO numbers entered in the range of [-100 100], Same as above, but check for the opposite condition. the average of negative numbers entered in the range of [-100 100], the average of negative numbers entered in the range of [-100 100], Similar to the above. Once you have determined whether a number is negative or positive, how are you going to keep track of it? Again, you'll need to store it somewhere. After you do that, I assume you know how to find the average. and the average of positive numbers entered in the range of [-100 100]. Same as above, but check for the opposite condition.
The printing should be trivial if you got the above right.
and the average of positive numbers entered in the range of [-100 100]. Same as above, but check for the opposite condition.
The printing should be trivial if you got the above right.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.