Question

Write a complete program in C that reads a set of integers using scanf() until a...

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.

Homework Answers

Answer #1

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

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
/*C PROGRAMMING: HOW TO INSERT ERROR BELOW CODE? QUESTION: This program reads integers from standard input....
/*C PROGRAMMING: HOW TO INSERT ERROR BELOW CODE? QUESTION: This program reads integers from standard input. The first integer indicates the number of values that will follow. Read that many values, and return their sum, ignoring any additional values that may follow. However, if there are fewer integers than specified in the input, print "Error" and terminate. Hint: int n, success; ... success = scanf("%d", &n); // FIRST INTEGER INPUT reads an integer from stdin, returning 1 if the integer...
Shell Programming Question: Write a shell program that reads a set of integers {125, 0, 122,...
Shell Programming Question: Write a shell program that reads a set of integers {125, 0, 122, 129, 0, 117}, and then prints a set of integers {125, 122, 129, 117}. Tips: Remove zeros **Write comments for code
Write a C++ program that reads two integers from the user. The program should tell whether...
Write a C++ program that reads two integers from the user. The program should tell whether the two numbers are equal or not.
C++ [Program-2] Write a program that accepts an indefinite set of numbers until the user enters...
C++ [Program-2] Write a program that accepts an indefinite set of numbers until the user enters “-1”. In other words, the program keeps accepting new values until the user provides a “-1” (your program accepts all values, and discards the “-1”). When done, the program prints back to the user: (i) the sum of all numbers entered (except -1), (ii) the minimum value seen across all numbers (except -1), and (iii) the maximum value across all numbers (except -1).
(Write in C++) Write a program that reads in two numbers and, if the input is...
(Write in C++) Write a program that reads in two numbers and, if the input is valid, outputs 2 times the product of the integers that lie between the two values (including the values themselves). If either number is not an integer, or if the first number is not less than the second number, just output an error message. The sample runs below should give the idea. User inputs are in bold. Important Notes: Your program should use a loop...
Write a C program that asks the user to enter two integers x and n. Then...
Write a C program that asks the user to enter two integers x and n. Then the program computes xn (=x * x * x …… (n times)) using for loop. using printf scanf
Its a c++ task. Write a program that reads 10 integers from the user into an...
Its a c++ task. Write a program that reads 10 integers from the user into an array and uses a function arrayMinimum that accepts an integer array a along with its size arraySize as parameters and returns the smallest array element. The program then outputs the result (the smallest array element).
In Coral,write a program that reads a list of 10 integers and outputs those Integers in...
In Coral,write a program that reads a list of 10 integers and outputs those Integers in Reverse. For coding Simplicity, follow each output integer by a space, including the last one. Then, output a new line. Example if the input is 2 4 6 8 10 12 14 16 18 20, the output is: 20 18 16 14 12 10 8 6 4 2 to achieve above first read the integers into an array. Then output the array in reverse
(C++) 5.15 LAB: Two smallest numbers with arrays Write a program that reads a list of...
(C++) 5.15 LAB: Two smallest numbers with arrays Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input begins with an integer indicating the number of integers that follow. Ex: If the input is: 5 10 5 3 21 2 the output is: 2 3 You can assume that the list of integers will have at least 2 values. To achieve the above, first read the integers...
Write a program in C++ that reads integer values from standard input and writes to standard...
Write a program in C++ that reads integer values from standard input and writes to standard output the smallest of the inputs and the average input value. The program should stop reading when a value equal to -1 or greater than 100 is encountered. It should also stop when an incorrect integer value (i.e., anything that isn't an int) is entered. If there is not an integer value in the input, the program should output "no integers provided"
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT