Write a C++ Program to display Names, Roll No., and grades of 3 students who have appeared in the examination. Declare the class of name, Roll No. and grade. Create an array of class objects. Read and display the contents of the array.
Write a C++ Program to display Names, Roll No., and grades of 3 students who have appeared in the examination. Declare the class of name, Roll No. and grade. Create an array of class objects. Read and display the contents of the array.
appeared in the examination. Declare the class of name, rollno and Grade. Create an array
of class objects. Read and Display the contents of the Array.
#include <iostream>
class student
char name[50];
int rollno;
int total;
public:
};
void student::readDetails(void)
cin>>name;
cin>>rollno;
cin>>total;
}
void student::gradeCal(void)
float percentage;
percentage=(float)total/500.00*100.00;
cout<<percentage<<"%\n";
if(percentage>=75.00)
{cout<<"Grade: A \n";}
else{ if((percentage>=60.00)&&(percentage<75.00))
{cout<<"Grade: B \n";}
else{ if((percentage>=40.00)&&(percentage<60.00))
{cout<<"Grade: C \n";}
else
{cout<<"Grade: D \n";}
}}
void student::printDetails(void)
cout<<"Name: "<<name<<endl;
cout<<"Rollnumber "<<rollno<<endl;
cout<<"Total: "<<total<<endl;
}
int main()
int n, i;
cin>>n;
std[i].readDetails();
std[i].printDetails();
std[i].gradeCal();
return 0;