C++ Program to Implement Parallel Array

This C++ Program demonstrates the implementation of Parallel Array.

Here is source code of the C++ Program to demonstrate the implementation of Parallel Array. The C++ program is successfully compiled and run on a Linux system. The program output is also shown below.

  1. /*
  2.  * C++ Program to Implement Parallel Array
  3.  */
  4. #include <iostream>
  5. #include <iomanip>
  6. #include <string>
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     int i = 0, h = 0, saved = 0; 
  12.     int g[ ] = {87, 99, 70, 75, 77, 91, 95};
  13.     string s [ ]= {"S1", "S2", "S3", "S4", "S5", "S6", "S7"};
  14.     for(i = 0; i < sizeof(g)/sizeof(g[0]); i++)
  15.     {
  16.         if (g[i] > h)
  17.         {
  18.             h = g[i];
  19.             saved = i;
  20.         }
  21.     }
  22.     cout << "Highest marks:" << h << " of Student: " << s[saved]<<endl;
  23.     return 0;
  24. }

$ g++ parallel_array.cpp
$ a.out
 
Highest marks:99 of Student: S2
 
------------------
(program exited with code: 1)
Press return to continue

Sanfoundry Global Education & Learning Series – 1000 C++ Programs.

advertisement
advertisement
If you wish to look at all C++ Programming examples, go to C++ Programs.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.