Write A C++ Program To Display The Student Data L
Write A C++ Program To Display The Student Data L
Navigation . / - , ( 7
$ Mar 28 2018
Computer Science Programming
MCQ
Smart Code
For YOU
Home ! Classes ! 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;
}
Thanks
Mukesh Rajput
& Classes
Share To:
' ( ) * + , -
Next
" C++ program to demonstrate example of friend
function with class.
Previous
Write a C++ program which calculate addition of two
number with the help of class. #
Mukesh Rajput
I am a Computer Engineer, a small
amount of the programming tips as it’s
my hobby, I love to travel and meet
people so little about travel, a fashion
lover and love to eat food, I am investing a good time to
keep the body fit so little about fitness also..
( ' . /
RELATED ARTICLES
1 comments:
CATEGORIES
4 Arrays
4 Classes
4 Files Programing
4 Functions
4 Home
4 Looping
4 Pointers
4 Sorting
4 Strings
4 Structure
LIKE US ON FACEBOOK