#include <iostream>
#include <stdio.h>
using namespace std;
class student
{
private:
int rollno;
char name[20];
int marks;
float fee;
public:
void getdata()
{
cout<<"\nEnter Roll no : ";
cin>>rollno;
fflush(stdin);
cout<<"Enter name : ";
gets(name);
cout<<"Enter Marks : ";
cin>>marks;
cout<<"Enter fee : ";
cin>>fee;
}
void putdata()
{
cout<<"\nRollno is : "<<rollno;
cout<<"\nName is : "<<name;
cout<<"\nMarks is : "<<marks;
cout<<"\nFee is : "<<fee;
}
};
int main()
{
student st;
cout<<"\n**********************************";
cout<<"\n**********************************";
cout<<"\n****Program to create a class*****";
cout<<"\n*******and a single object********";
cout<<"\n**and access the class functions**";
cout<<"\n****Created by : Sheetal Garg*****";
cout<<"\n********Assistant Professor*******";
cout<<"\n*******Phone No: 9467863365*******";
cout<<"\n**********************************";
cout<<"\n**********************************";
st.getdata();
st.putdata();
return 0;
}
Output:
********************************** ********************************** ****Program to create a class***** *******and a single object******** **and access the class functions** ****Created by : Sheetal Garg***** ********Assistant Professor******* *******Phone No: 9467863365******* ********************************** ********************************** Enter Roll no : 1 Enter name : Sheetal Garg Enter Marks : 500 Enter fee : 50000.00 Rollno is : 1 Name is : Sheetal Garg Marks is : 500 Fee is : 50000