Whats in this post?
- Background and Explanation of the code
To copy code: Click “View Source” on the right of this code snippet.
Background and Explanation of the code
The above program is used to calculate the average percentage of marks obtained in a particular subject by n students of a class using static members.The class student contains a static data member tot_marks which will store the sum of marks of n students in a particular subject.The class also contains a static member function avg_per_marks ( ) that calculates and display average percentage of marks.On execution,we input the roll number,marks of n students of a class and average percentage of marks in a particular subject is calculated and displayed.
Enter number of students : 2
Enter rollno and marks : 10 60
Enter rollno and marks : 11 70
Average percentage of marks is = 65