-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex_3_7_2.cpp
More file actions
35 lines (28 loc) · 803 Bytes
/
Copy pathex_3_7_2.cpp
File metadata and controls
35 lines (28 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
using namespace std;
int main(){
//declare the array and the other variables
float gradeArray[10];
float gradeSum, gradeAverage;
int i;
//put some grades into the array
for (i=0; i<10;) {
gradeArray[i] = 0;
cout << "Enter number " << i << endl;
cin >>gradeArray[i];
i++;
}
//initialize the gradeSum variable to be 0
gradeSum = 0;
//loop through each location in gradeArray (there are 5)
for(i=0; i<10; i++){
//add the value of the thing stored at location
//i in gradeArray to gradeSum
gradeSum += gradeArray[i];
}
//to finish the average, divide gradeSum by 5
gradeAverage = gradeSum/5;
//print out the average
cout << "Your average is " << gradeAverage << ".\n";
return 0;
}