Write a C++ program to display the student data like name, roll-no, total marks and percentage with the help of a class.
Program Code:
#include <iostream>
using namespace std;
class student
{
private:
char name[30];
int rollNo;
int total;
float perc;
public:
//member function to input student's details from user
void getdata()
{
cout << "Enter name: " ;
cin >> name;
cout << "Enter roll number: ";
cin >> rollNo;
cout << "Enter total marks out of 700: ";
cin >> total;
perc=(float)total/700*100;
}
//member function to display student's details
void putdata()
{
cout << "Student details:";
cout<<endl;
cout << "Name of student :"<< name;
cout<<endl;
cout<< "Roll Number of student :" << rollNo;
cout<<endl;
cout<< "Total marks of student :" << total;
cout<<endl;
cout<< "Percentage of student :" << perc;
}
};
int main()
{
//object declaration of class student
student obj;
obj.getdata();
obj.putdata();
return 0;
}
The program code is tested on www.jdoodle.com
Output:
Enter name: Mukesh
Enter roll number: 102
Enter total marks out of 700: 500
Student Detail:
Name of student : Mukesh
Roll Number of student : 102
Total marks of student : 700
Percentage of student : 71.42
Thanks
Mukesh Rajput





Write A C++ Program To Display The Student Data Like Name, Roll-No, Total Marks And Percentage With The Help Of A Class. - Smart Code For You >>>>> Download Now
ReplyDelete>>>>> Download Full
Write A C++ Program To Display The Student Data Like Name, Roll-No, Total Marks And Percentage With The Help Of A Class. - Smart Code For You >>>>> Download LINK
>>>>> Download Now
Write A C++ Program To Display The Student Data Like Name, Roll-No, Total Marks And Percentage With The Help Of A Class. - Smart Code For You >>>>> Download Full
>>>>> Download LINK