Example:
#include<iostream.h>
#include<conio.h>
class student
{
protected:
int id;
char name[20];
public:
void get();
};
class
marks : public student
{
private:
int english, french,
maths, total;
public:
void getdata();
};
class sports
{
protected:
int
sm;
public:
void
take();
};
Class result : public marks, public sports
{
float
avg;
public:
void
getresult();
};
void
student :: get()
{
cout<<”Enter the Student Info = ”;
cin>>id>>name;
}
void
marks :: getdata()
{
cout<<”Enter Marks = ”;
cin>>english>>french>>maths;
}
void sports :: take()
{
cout<<”Enter Sports Marks = ”;
cin>>sm;
};
Void result :: getresult()
{
total
= english+french+maths+sm;
avg
= total/4;
cout<<id<<name;
cout<<
English<<French<<maths<<sm<<total<<avg;
};
void main()
{
clrscr();
result
r;
r.get();
r.getdata();
r.take();
r.getresult();
getch();
}
c++ codings example for beginners
ReplyDeletec++ program | Quick Sort Program with Text Graphics