Tuesday 6 August 2013

Multiple Inheritance(4)

#include<iostream.h>
#include<conio.h>
class student
{
    public:
        int rn;
        void putn(int);
        void shown(void);
};
void student::putn(int a)
{
    rn=a;
}
void student::shown()
{
    cout<<"\n Roll Number= "<<rn;
}
class marks:public student
{
    public:
        int m1,m2,m3;
        void putm(int,int,int);
        void showm(void);
};
void marks::putm(int a,int b,int c)
{
    m1=a;
    m2=b;
    m3=c;
}
void marks::showm()
{
    cout<<"\n Marks of Basic: "<<m1;
    cout<<"\n Marks of C language: "<<m2;
    cout<<"\n Marks of Java: "<<m3;
}
class t:public marks
{
    public:
        int total,avg;
        void t1(void);
        void showt(void);
};
void t::t1()
{
    total=m1+m2+m3;
    avg=total/3;
}
void t::showt()
{
    cout<<"\n Total= "<<total;
    cout<<"\n Average= "<<avg;
}
class g:public t
{
    public:
        int grade;
        void g1(void);
};
void g::g1()
{
    if(avg>=80)
        cout<<"\n Distinction";
    else if(avg>=60 && avg<80)
        cout<<"\n First Class";
    else if(avg>=45 && avg<60)
        cout<<"\n Second Class";
    else if(avg>=35 && avg<45)
        cout<<"\n Pass Class";
    else
        cout<<"\n Fail";
}
void main()
{
    clrscr();
    g rup;
    rup.putn(331);
    rup.shown();
    rup.putm(95,95,95);
    rup.showm();
    rup.t1();
    rup.showt();
    rup.g1();
    getch();
}

Here Is The Output :)

 

No comments:

Post a Comment