Parallel Arrays in C++:
In this tutorial, I show you more about using Arrays in C++. In the last tutorial, I've shown you some very basics of how arrays work, here I show you how to work with Parallel Arrays, also known as multiple arrays. Here You calculate and output results very easily.
Arrays are very helpful. This tutorial only handle single dimensional arrays but deals with multiple array variables as well as implement the 'for' loop for more practice.
I hope you enjoy the video and if you have any requests feel free to let me know. Thanks for watching ! Thanks for watching and thanks for your supportand remember to subscribe!
#include <iostream>
#include <string>
using namespace std;
int main(){
string name[3];
int test1[3];
int test2[3];
float avg[3];
int i;
for(i=0;i<=2;i++){
cout << "Please enter student's name: ";
cin >> name[i];
cout << "Please enter first test score: ";
cin >> test1[i];
cout << "Please enter second test score: ";
cin >> test2[i];
}
for(i=0;i<=2;i++){
avg[i] = (test1[i] + test2[i]) / 2;
}
cout << endl;
cout << "Name" << " " << "Average" << endl;
for(i=0;i<=2;i++){
cout << name[i] << " " << avg[i] << endl;
}
system("pause");
}