#include<iostream.h>
#include<stdio.h>
#include<conio.h>
class stu{
public:
int roll,m[3];
char name[45];
void input()
{
cout<<"Enter roll number:";
cin>>roll;
cout<<"Enter name:";
gets(name);
cout<<"Enter marks of three subjects:";
cin>>m[0]>>m[1]>>m[2];
}
int total()
{
return(m[0]+m[1]+m[2]);
}
void display()
{
cout<<"Name:"<<name<<"\tRoll number: "<<roll;
cout<<"\nMarks of three subjects: "<<m[0]<<'\t'<<m[1]<<'\t'<<m[2];
cout<<"\n\tTotal marks= "<<total();
cout<<endl;
}
};
void main()
{
stu s1,s2;
s1.input();
s2.input();
s1.display();
s2.display();
getch();
clrscr();
}
#include<stdio.h>
#include<conio.h>
class stu{
public:
int roll,m[3];
char name[45];
void input()
{
cout<<"Enter roll number:";
cin>>roll;
cout<<"Enter name:";
gets(name);
cout<<"Enter marks of three subjects:";
cin>>m[0]>>m[1]>>m[2];
}
int total()
{
return(m[0]+m[1]+m[2]);
}
void display()
{
cout<<"Name:"<<name<<"\tRoll number: "<<roll;
cout<<"\nMarks of three subjects: "<<m[0]<<'\t'<<m[1]<<'\t'<<m[2];
cout<<"\n\tTotal marks= "<<total();
cout<<endl;
}
};
void main()
{
stu s1,s2;
s1.input();
s2.input();
s1.display();
s2.display();
getch();
clrscr();
}
No comments:
Post a Comment