Student Report using inheritance In C++

C++

Student Report using inheritance In C++ OOPs in HindiC++ Inheritance Ka Istemal Karke Ham Student Report Program Ko Banane Wale Hai |

Also Read – Become A Web Developer In Hindi

Student Report using inheritance

C++ Inheritance Allows Karta Hai Hame Ki Class Define Karo Or Uske Bad Ham Inherits Kar Sakte Hai All Methods And Properties Yani Dusri Class Ke.

For Example– Derived Class Kar Sakta Hai Parent Class Ke Properties Ko Istemal |

Ek Bar Ek Parent Class Ko Create Karne Ke Bad Ham Parent Class (Base Class ) Ko Ham Derived Class (Sub Class ) Me Istemal kar Sakte Hain And Parent Class Or Derived Class Ke Features To Alag-Alag Honge Hi. Lekin Ham Derived Class Se Parent Class Ke Features Ka Istemal Kar Sakte Hain |

Inheritance OOP Ka Ek Part Hota Hain And Inheritance Mai Ek Se Jyada Classes Hote Hain |

Ab Tak Keval Theory Ko Understand Kiya Hai, Ab Ham Inheritance Ka Istemal karke Student Report Generate Karenge With Output ke Sath |

Example:

#include<iostream>
#include<string>
using namespace std;
class Student
{ 
    int roll;
    string name;
    string address;
    string city;

    public: student()
    { 
        cout<<endl<<"Welcome to the Student Information System";
        cout<<endl<<"*****************************************";
    }
    void getdata()
    { 
        cout<<endl<<"Enter student roll number:";
        cin>>roll;
        cout<<endl<<"Enter student name:";
        cin>>name;
        cout<<endl<<"Enter student address:";
        cin>>address;
        cout<<endl<<"Enter student city:";
        cin>>city;
    }
    void putdata()
    { 
        cout<<endl<<"The student roll number:"<<roll;
        cout<<endl<<"The student name:"<<name;
        cout<<endl<<"The student address:"<<address;
        cout<<endl<<"The student city:"<<city;
    }
};
class marks: public Student
{ 
    int sub1;
    int sub2;
    int sub3;
    int per;
    public:
        void input()
        { 
            getdata();
            cout<<endl<<"Enter the marks1:";
            cin>>sub1;
            cout<<endl<<"Enter the marks2:";
            cin>>sub2;
            cout<<endl<<"Enter the marks3:";
            cin>>sub3;
        }
    void output()
    { 
        cout<<endl<<"Student Details:";
        cout<<endl<<"****************";
        putdata();
        cout<<endl<<"Marks1:"<<sub1;
        cout<<endl<<"Marks2:"<<sub2;
        cout<<endl<<"Marks3:"<<sub3;
    }
    void calculate()
    { 
        per=(sub1+sub2+sub3)/3;
        cout<<endl<<"Total percentage:"<<per;
        if(per>=85)
        cout<<endl<<"Grade A+";
        else if(per>=60)
        cout<<endl<<"Grade A";
        else if(per>=50)
        cout<<endl<<"Grade B";
        else
        cout<<endl<<"Grade C";
    }
};

int main()
{ 
marks m1;
m1.input();
m1.output();
m1.calculate();
return 0;
}

Output:

Enter student roll number: 7005
Enter student name: Arshad
Enter student address: Dwaraka Nagar
Enter student city: Bangalore
Enter the marks1: 85
Enter the marks2: 75
Enter the marks3: 65
Student Details:
********************
The student roll number: 7005
The student name: Arshad
The student address: Dwaraka Nagar
The student city: Bangalore
Marks1: 85
Marks2: 75
Marks3: 65
Total percentage: 75
Grade A

Aap Upper Output Ko Dekh Kar Program Ko Understand Kar Sakte Hai, Isme Hamne Class Student & marks Create Karke And Fir Unke Value Ko Input Karaya Hai, Uske Bad Hame Unhe Print Kar Diya Hai WIth Amount Ke Sath |

Leave a Reply

Your email address will not be published.