Question: C++ Program: The program uses a string to number conversion function, atoi . It allows the user to enter a series of values, or the

C++ Program: The program uses a string to number conversion function, atoi. It allows the user to enter a series of values, or the letters 'Q' or 'q' to quit. The average of the numbers are then calculated and displayed. Fill in the missing codes.

// This program demonstrates the strcmp and atoi functions. #include #include > // For tolower #include // For strcmp #include // For atoi using namespace std; int main() { const int SIZE = 20; // Array size char input[SIZE]; // To hold user input int total = 0; // Accumulator int count = 0; // Loop counter double average; // To hold the average of numbers

// Get the first number for the user. cout << "This program will average a series of numbers. "; cout << "Enter the first number or Q to quit: "; cin >> input; --> (not sure if this is correct) // Process the number and subsequent numbers. while (_____________________ != 'q') {

_______________________; // Keep a running total

__________________________; // Count the numbers entered // Get the next number. cout << "Enter the next number or Q to quit: ";

___________________________; } // If any numbers were entered, display their average. if (______________) //avoid dividing by zero { average = static_cast(total) / count; cout << "Average: " << average << endl; } return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!