Write a complete program in C that reads a set of integers using scanf() until a sentinel value of -99 is read. Once that value is read, display the sum of the values, exclusive of the -99.
Solution
Code
#include <stdio.h>
void main()
{
int value,sumvalue;
printf("Enter sets of integers (-99 to stop):\n");
sumvalue = 0;
scanf ("%d", &value);
while (value!=-99)
{
sumvalue=sumvalue+value;
scanf ("%d", &value);
}
printf ("Sum = %d ", sumvalue);
}
Screenshot of the code
Screenshot of the output
--
all the best
please upvote
Get Answers For Free
Most questions answered within 1 hours.