Friday, 24 November 2017

C++ Program to Implement Parallel Array


Code:

#include   iostream
#include   iomanip
#include   string
using namespace std;

int main()
{
    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"};
    for(i = 0; i < sizeof(g)/sizeof(g[0]); i++)
    {
        if (g[i] > h)
        {
            h = g[i];
            saved = i;
        }
    }
    cout << "Highest marks:" << h << " of Student: " << s[saved]<
    return 0;
}


Output:

Highest marks:99 of Student: S2

------------------
(program exited with code: 1)
Press return to continue



More C++ Programs:















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...