Mark Sheet

Description:

Create a C++ class for student having following members. Rollno Name Number of subjects Marks of each subject (Number of subjects varies for each student) Write a parameterized constructor which initializes rollno,name & Number of subjects and creates the array of marks dynamically. Display the details of all students with percentage and class obtained. Test Case 1 Input (stdin) 2 Abc 571 2 87 76 Bcd 583 3 87 76 76 Expected Output Abc 571 81.5 Class A Bcd 583 79.6667 Class B Test Case 2 Input (stdin) 3 Ram 231 2 78 89 Shyam 254 3 67 89 90 Ravi 255 2 56 65 Expected Output Ram 231 83.5 Class A Shyam 254 82 Class A Ravi 255 60.5 Class C

Program :

#include <iostream>

using namespace std;

int main()

{

int n,i,j,m[20],a,t;

  float avg;

  float o=0;

  char s[50];

  cin>>n;

  for(i=0;i<n;i++)

  {

  cin>>s>>a>>t;

    cout<<s<<" "<<a<<" ";

    for(j=0;j<t;j++)

    {

      cin>>m[j];

      avg=avg+m[j];

      o++;

        }

    avg=avg/o;

    cout<<avg;

    if(avg>80)

      cout<<" Class A\n";

    else if(avg>70)

      cout<<" Class B\n";

    else

      cout<<" Class C\n";

        avg=0;

    o=0;

  }

return 0;

}