Answer:
#include <stdio.h>
#include <limits.h>
/* Define the number of times you are going
to ask the user for input. This allows you
to customize the program later and avoids the
hard coding of values in your code */
#define NUMVALS 5
int main(void)
{
int i = 0;
int curval = 0;
/* Set your initial max as low as possible */
int maxval = INT_MIN;
/* Set your initial min as high as possible */
int minval = INT_MAX;
/* Loop through and ask the user for the defined
number of values */
for (i = 0; i < NUMVALS; i++)
{
/* Ask the user for the next value */
printf("Enter the next value: ");
/* Get the next value from the user */
scanf("%d", &curval);
/* Check to see if this is our biggest or
smallest value yet */
if (curval > maxval)maxval = curval;
if (curval < minval)minval = curval;
}
/* Output the results */
printf("The smallest value entered was: %d \\", minval);
printf("The largest value entered was: %d \\", maxval);
/* End the program */
return 0;
}
Step-by-step explanation: