Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a C++ program that has a while-loop to loop indefinitely until an input of a value that is 0 or less. Hence, prompt
Write a C++ program that has a while-loop to loop indefinitely until an input of a value that is 0 or less. Hence, prompt user to enter a positive integer value and repeat as long as it is greater than 0. Here is start of the code 2 #include #include 34 3 using namespace std; 4 5 6 int num; 7 8 9 19 int main() { int sum = 0; int count = 0; double average; When exit the loop, calculate and then display the average to 2 decimal places. Remember that the values for variables sum and count depends on how many values entered. Here is a sample run of the complete program Enter an integer : 8 Enter an integer : 10 Enter an integer : 9 Enter an integer : 7 Enter an integer : Enter an integer : 5 Enter an integer : -5 Average is 7.33 (Ctrl)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
You can achieve the desired functionality using a whileloop to continuously prompt the user ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started