Question
1. // P2_3_2.cpp - Read and average 6 integers, print the result. #include using namespace std; int main(void) { int x; int count = 0;
1.
// P2_3_2.cpp - Read and average 6 integers, print the result.
#include
// prompt the user: cout << "Enter six grades separated by a single space, then press
average = sum/6; // compute the average, total divided by the number of grades cout << "The average is " << average << endl;
return 0; }
What are the differences between this program and the one given in P2_3_1.cpp? Exercise 2.3.1 Use a text editor to create a file called ex2_3_1.cpp. Copy and paste or carefully copy P2_3_2.cpp program in that file, and then change the program to compute the average of 100 numbers.
2.
// P2_3_3.cpp - Read and average N integers, print the result.
#include
// prompt the user: cout << "Enter number of values, N, to be read in
while( count < N) // (2) read N grades and compute their sum, count ensures N entries { // read each number and compute the sum: cout << " Enter a grade
if(N == 0) cout << "You haven't enter 0 number, no average will be computed, bye "; else{ average = average = sum/N; cout << "The average of these " << N << " grades is " << average << endl; }
return 0; }
Change program P2_3_3.cpp to work with a do while loop instead of while loop. Call your new program ex2_3_2.cpp, compile and run the program and make sure it produces the correct results.
need 2 of dem plz
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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