158k views
2 votes
1. A flowchart of this program. (Include the hand calculated expected output value. I pts)

2. Printout of your C++ program with a heading comment (with proper spacing and indentation)
3. Copy of a screenshot after your program is executed. (2 and 3: 2 pts cach)
4. Analyze the program and describe what makes the output to be different in plain English. ELEN 1381 Programming Assignment #4. Name Your name. Student ID : Your student ID #. Due date : Due date Purpose of the program : Calculate an average of four numbers. Section 1 : Enter four numbers. Section 2 : Calculate the average and display the answer. Section 3 : Calculate the average and display the answer. #include using namespace std; int main() int ni, n2, n3, n4, a; double b; // Section 1. cout << "Enter last digit of your Student ID : "; cin >> ni; cout << "Enter last digit of your Student ID +1: "; cin >> n2; cout << "Enter last digit of your Student ID + 2 : "; cin >> n3; cout << "Enter last digit of your Student ID + 4 : "; cin >> n4; // Section 2. a = (nl + n2 + n3 + 04) / 4; cout << "The average is : " < a << endl; 1/ Section 3. b = (nl + n2 + n3 + n4) / 4.0; cout << "The average is : " << b << endl; ; return ) // main

User Davison
by
4.3k points

1 Answer

0 votes

Answer:

See Explanation

Step-by-step explanation:

1. See Attachment 1 (image file) for flowchart

2. & 3. See Attachment 2 for source file (Note that I've made some corrections on the source code)

4. What makes the outputs (a and b) to be different is that;

a calculates the average of the given parameters as a = (ni+n2+n3+n4)/4

While

b calculates a different expression = (ni+n2+n3+04)/4

They will only have the same output if n4 = 4

1. A flowchart of this program. (Include the hand calculated expected output value-example-1
User TechAurelian
by
4.5k points