Write a program which reads a sequence of real values filled by the user and stops by displaying "FINISHED" when the sum of these values exceeds 100.
Difficulty level
Video recording
This exercise is mostly suitable for students
#include <stdio.h>
int main()
{
int nb, sum;
sum = 0;
do{
printf("Enter a number: ");
scanf("%d", &nb);
sum+=nb;
}while(sum<100);
printf("Sum = %d \n",sum);
return 0;
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Check whether the first N characters of two strings are equal using an iterative function