#include <stdio.h>
int main() {
int sum = 0, count = 0, num;
while (1) {
printf("Enter an integer(negative to exit): ");
scanf("%d", &num);
if (num < 0) {
break;
}
sum += num;
++count;
}
printf("Sum = %d\n", sum);
printf("Average = %lf\n", sum/(double)count);
return 0;
}
Answer using programming in C only. 6 pts Use a while loop to complete the following:...
17. (2 points) C++ Using a while loop, write the code statements to sum 10 integers entered by a user. Display the sum. Hint: Be sure to declare, initialize, and use appropriate variables to count the repetitions and accumulate the sum.
This is for C++ programming: Write a while loop that finds the average of all of the whole numbers entered from the user, until a -1 is entered (the -1 should not be included in the calculation of the average.
In C++ Programming, Try using loops only. This lab demonstrates the use of the While Loop and the Do While Loop as error checking mechanisms. You will be using each of these loops to solve the same problem. Please put them both in the same program. When you test the code, you will not see a difference in the way they execute - but there will be a difference in the logic when writing the code. You will want to...
C++ Programming Help Please! NOTE: Please READ All Steps very carefully. DO #10! (10 is based off of 9). Program Info: #9. Write a program that reads in ten whole numbers and that outputs the sum of all the numbers greater than zero, the sum of all the numbers less than zero (which will be a negative number or zero), and the sum of all the numbers, whether positive, negative, or zero. The user enters the ten numbers just once...
Sum of Numbers: Write a program that asks the user for a positive integer value.The program should use a loop to get the sum of all the integers from 1 up to the number entered.For Example, if the user enters 50, the loop will find the sum of 1,2,3,4,…50.C++
(java) Write a While loop that prompts the user for only even numbers. Keep prompting the user to enter even numbers until the user enters an odd number. After the loop ends, print the sum of the numbers. Do not include that last odd number. You should not store the numbers in an array, just keep track of the sum. Make sure to use a break statement in your code. You may assume that a java.util.Scanner object named input has...
need help!! c++
HW_6b - Calculate the average Use a do-while loop Write a program that first prompts the user for an upper limit: Enter the number of entries: 5 € (user enters 5) After the user enters a number, the program should prompt the user to enter that many numbers. For example, if the user enters 5, then the program will ask the user to enter 5 values. Use a do-while loop to add the numbers. o With each...
Objectives:
Use the while loop in a program
Use the do-while loop in a second program
Use the for loop in a third program
Instructions:
Part A. Code a for loop to print the Celsius temperatures for
Fahrenheit temperatures 25 to 125. C = 5/9(F – 32).Output should be
in a table format:
Fahrenheit Celsius
25 ?
. .
. . . .
. .
Turn in the source and the output from Part A.
Part B. Code a while...
Answer each of the following questions about loops in C++. In each question, LABEL the three parts of the loop. a.) Write a while statement that will ask the user for integers until the user enters the sentinel value of -1. Declare all needed variables. b.) Write a for statement that will print out all the multiples of 3 between 1 and 200. Declare any needed variables. c.) Write a do while loop that will ask the user for characters...
write a programming code for the following problem using
Visual Basic Studio VB.
Write a program that will allow the user to enter series of mumbers and will give some useful statistics about the mambers Enter Numbers Button Click-Allow the user to enter series of nambers using imput dialog boxes. Use a loop and add the numbers to the listBox as they are input.. Prompt the user to enter"x" to stop addang numbers. Compute Statistics Button Click-Compute the following statistics...