Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void readData();
- int calTotMarks(int[]);
- void display();
- const int STUDENTS = 5;
- int studMarks[STUDENTS][5], totMarks[STUDENTS];
- int main()
- {
- readData();
- for(int i=0; i<STUDENTS; i++) //pass row by row array
- totMarks[i] = calTotMarks( studMarks[i] );
- display();
- }
- void readData()
- {
- cout << "Enter 5 marks for each student:\n";
- for(int i=0; i<STUDENTS; i++)
- {
- cout << "Student " << i+1 << " : ";
- for(int j=0; j<5; j++)
- cin >> studMarks[i][j];
- }
- }
- int calTotMarks(int subject[])
- {
- int total=0;
- for(int i=0; i<5; i++)
- total += subject[i];
- return total;
- }
- void display()
- {
- cout << "\nStudent\tMark1\tMark2\tMark3\tMark4\tMark5\tTotalMarks\n";
- for(int i=0; i<STUDENTS; i++)
- {
- cout << i+1 << "\t" ;
- for(int j=0; j<5; j++)
- cout << studMarks[i][j] << "\t";
- cout << totMarks[i] << endl;
- }
- }
Add Comment
Please, Sign In to add comment