Find answers to your most challenging questions with the help of IDNLearn.com's experts. Our experts provide accurate and detailed responses to help you navigate any topic or issue with confidence.
Sagot :
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 \n", minval);
printf("The largest value entered was: %d \n", maxval);
/* End the program */
return 0;
}
Explanation:
We value your participation in this forum. Keep exploring, asking questions, and sharing your insights with the community. Together, we can find the best solutions. Your questions deserve accurate answers. Thank you for visiting IDNLearn.com, and see you again for more solutions.