Hi, I am writing a program that requires user determined input at the beginning of the program. I must ask the user to input a number that will determine the number of integers that the user will put in later. My question is, how do you specify in the program to take that number entered in implement it later so when they are entering integers, it won't allow any more than they already specified.
Code:
#include <stdio.h>
int main (void)
{
int num;
double fah;
double cel;
printf ("Please enter the number of temperatures you will be entering:\n\n ");
scanf ("%i", &num);
while ( (num < 1) || (num > 25) )
{
printf ("The value you entered is out of range, please input a value between 1 and 25:\n\n ");
scanf ("%i", &num);
}
printf ("Now input your %i Fahrenheit temperature values:\n\n ", num);
scanf ("%lf", &fah);
while ( (fah < -125.0) || (fah > 125.0) )
{
printf ("%.1lf is out of range, please input a value between -125.0 and 125.0:\n\n ", fah);
scanf ("%lf", &fah);
}
return 0;
}
That is all I have so far. Later in the program I also have to use the numbers inputed to calculate averages and the like.
Any thoughts?
Thank you.