Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke, David J. Auer

7th edition

133544621, 133544626, 0-13-354462-1, 978-0133544626

More Books

Students also viewed these Databases questions

Question

Let X2 ~ F(1,n). Show that X ~ t(n).

Answered: 1 week ago

Question

What will be you living situation/home environment?

Answered: 1 week ago

Question

How many stores exceeded the KPI target in 2015?

Answered: 1 week ago