C++ Multi-level inheritance
Submissions: 506   Accuracy:

61.29%

  Difficulty: Easy   Marks: 2

Ankit is a very competitive person and always tries to compare him to other. He has got 5 subjects in his course and he wants to make a list of total marks and average marks of the students in his class with their roll numbers. He wants to use the concept of multi-level inheritance doing this. Help him achieve the required goal.   

Student class is already been created.

Create 2 classes:

  • Test: containing the marks of a student in 5 subjects inheriting class student ( having roll number of the student).
  • Result: containing the function Display() to compute the total and average and then displaying the output as Roll number, total and average which are space separated.

Input:

Most of the input is handled for you by the locked code in the editor.

  • The first line will contain the number of test cases(number of students)
  • Each test case has roll number of student in the first line followed by 5 space separated floating numbers in the second line.

Output:

For each test case or student, the output should consist of 3 space-separated values- Roll number, total marks, average marks 

Constraints: 

1 < T <= 100

1 < n < 100

0 <= marks <= 100
 

Example:

Input:

3
1
10 10 10 10 10
2
8 8 8 8 8 

7 7 7 7 7

Output:

1 50 10
2 40 8
3 35 7

** For More Input/Output Examples Use 'Expected Output' option **

Author: Archit18_PEC


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.