The Parallel array can store multiple fields of data for several items at a time. Series of data values store in array which can be accessed by their index number. The Parallel array size should be same. In this problem we will calculate the average score of the student in a quiz within the series of their name.
Source Code
#include <iostream> #include <string> #include <windows.h> using namespace std; int main()
{ string name[2]; int Quiz_1[2]; int Quiz_2[2]; float AverageScore[2]; int i; cout<<"\n\t\t Parallel Array \n\n\n"; for(i=0;i<=1;i++){ cout<<"\n"; cout << "Student Name : "; cin >> name[i]; cout << "Enter Quiz_1 Marks : "; cin >> Quiz_1[i]; cout << "Enter Quiz_1 Marks : "; cin >> Quiz_2[i]; } for(i=0;i<=1;i++){ AverageScore[i] = (Quiz_1[i] + Quiz_2[i]) / 2; } cout << endl; cout << " Name " << " " << " Average " << endl; for(i=0;i<=1;i++){ cout << name[i] << " " << AverageScore[i] << endl; } system("pause"); }
0 comments:
Post a Comment