-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChallenge1_ParallelArrays.cpp
More file actions
45 lines (44 loc) · 1.01 KB
/
Challenge1_ParallelArrays.cpp
File metadata and controls
45 lines (44 loc) · 1.01 KB
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
36
37
38
39
40
41
42
43
44
45
#include <iostream>
using namespace std;
/*Challenge#1:
Using Parallel Arrays to enter Names, Exercise Marks and Compute Average of Exercise Marks and
Display*/
const int arraylenght = 5;
string name[arraylenght];
float marks[arraylenght];
// prototype
void storingUserValue();
float average();
// void display();
int main()
{
float classaverage;
storingUserValue();
classaverage = average();
cout << "Class Average marks is: " << classaverage << "%";
// display();
}
void storingUserValue()
{
for (int i = 0; i < arraylenght; i++)
{
cout << "Enter student name : ";
cin >> name[i];
cout << "Enter marks : ";
cin >> marks[i];
}
}
float average()
{
float totalMarks; // store total marks
float totalAverage; // store total average
for (int i = 0; i < arraylenght; i++)
{
totalMarks += marks[i];
}
totalAverage = (totalMarks / 500) * 100;
return totalAverage;
}
// void display()
// {
// }