Code:
#include <stdio.h>
int main (void)
{
int value, sum = 0;
printf ("Enter a value: ");
scanf ("%i", &value);
while ( sum > 100 )
{
scanf ("%i", &value);
}
while ( (value < 0) || (value > 25) )
{
printf ("Out of range, please re-enter: ");
scanf ("%i", &value);
}
sum = sum + value;
printf ("\nThe sum is: %i\n\n", sum);
return 0;
}
This program is to take user entered integers ranging from 0 to 25 until the sum of those entered integers is equal to or in excess of 100. I know the 0 to 25 constraint works fine, it's the sum part that isn't so fine.
Currently what the program does is it takes the first acceptable entered integer and just prints that as the sum as well. Ex: if I input 25 it will say the sum is 25.
It should keep asking for numbers until a sum of 100 or greater is reached.