I'm suppose to write a program that uses two parallel arrays to store student names and their grades. It should use an array of strings that hold the names and and array of integers that hold the grades. The program should produce a report that displays list of students names and grades, and the name of the student that has the highest grade. The names and grades should be stored using an initialization list at the time the arrays are created. Use a loop and conditional statement to determine which student has the highest grade.
This is what I have tried so far. I'm new at this and there not many good examples in the book
Code:
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int i = 0, h = 0, saved = 0;
int g[ ] = {87, 99, 70, 75, 77, 91, 95};
string s [ ]= {"S1", "S2", "S3", "S4", "S5", "S6", "S7"};
while ( i <= 3)
{if (g[i] > h)
{h = g[i];
saved = i;
}
}
cout << "Highest " << h;
cout << "student is " << s[saved];
return 0;