Question
write a program that reads a series of integers, stopping when the user enters the value zero. The user should print out the number of
write a program that reads a series of integers, stopping when the user enters the value zero. The user should print out the number of values read and the maximum and minimum values seen. You can assume there will always be at least one number entered.
My code:
#include
int i = 0; int value[20]; int max = 0; int min = 0;
for (i = 0; value[i]!= 0; ++i){
scanf("%d", &value[i]);
if (value[i] > value[i+1]){
max = value[i]; } else { max = value[i+1]; } if (value[i] < value[i]){ min = value[i]; } else { min = value[i+1];
} } printf("Maximum Value is : %d ", max); printf("Minimum Value is : %d ", min); printf("Count of numbers is : %d ", i); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started