Thursday 4 July 2013

Simple Program of student details in C++

Write a simple Program to create student details in C++ such as roll number, name,marks,percentage etc..


#include<iostream.h>
#include<conio.h>
class student
{
private:
int rollno,m1,m2,m3,total,per;
char name[20];

public:
void putdata()
{
cout<<"\n Enter Student Roll Number: ";
cin>>rollno;
cout<<"\n Enter Student Name: ";
cin>>name;
cout<<"\n Enter Marks of C language: ";
cin>>m1;
cout<<"\n Enter Marks Of Java: ";
cin>>m2;
cout<<"\n Enter Marks of DotNet: ";
cin>>m3;
}

void calculate()
{
total=m1+m2+m3;
per=total/3;
}

 void getdata()
{
cout<<"\n Student Roll Number= "<<rollno;
cout<<"\n Student name: "<<name;
cout<<"\n Marks of C Language= "<<m1;
cout<<"\n Marks of Java= "<<m2;
cout<<"\n Marks of DotNet= "<<m3;
cout<<"\n Total Marks= "<<total;
cout<<"\n Percentage= "<<per;
}
};

void main()
{
clrscr();
student d;
d.putdata();
d.calculate();
d.getdata();
getch();
}


Here is the output:->


 

No comments:

Post a Comment