Q:

C++ Program display Student Marksheet using Multiple inheritance

belongs to collection: C++ Inheritance Solved Programs

0

Write a C++ Program display Student Marksheet using Multiple inheritance. Here’s a Simple C++ Program display Student Marksheet using Multiple inheritance in C++ Programming Language.

What are Inheritance in C++ ?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

  • Inheritance allows us to define a class in terms of another class, which makes it easier to create and maintain an application. This also provides an opportunity to reuse the code functionality and fast implementation time.
  • When creating a class, instead of writing completely new data members and member functions, the programmer can designate that the new class should inherit the members of an existing class. This existing class is called the base class, and the new class is referred to as the derived class.
  • The idea of inheritance implements the is a relationship. For example, mammal IS-A animal, dog IS-A mammal hence dog IS-A animal as well and so on.

Types of Inheritance : :

There are different types of inheritance : :

 
 
  • Single Inheritance
  • Multiple Inheritance
  • Multilevel Inheritance
  • Hierarchical Inheritance
  • Hybrid (Virtual) Inheritance

Below is the source code for C++ Program display Student Marksheet using Multiple inheritance which is successfully compiled and run on Windows System to produce desired output as shown below :


SOURCE CODE : :

/*  C++ Program display Student Marksheet using Multiple inheritance  */

#include<iostream>
#include<stdio.h>

using namespace std;
class student
{
        int roll;
        char name[25];
        char add [25];
        char city[25];
        public:
    student()
        {
                cout<<"  welcome in the student information system  "<<endl;
        }
        void getdata()
        {
                cout<<"\n enter the student roll no.  ";
                cin>>roll;
                cout<<"\n enter the student name  ";
                cin>>name;
                cout<<"\n enter ther student address  ";
                cin>>add;
                cout<<"\n enter the student city  ";
                cin>>city;
        }
        void putdata()
        {
                cout<<"\n the student roll no: "<<roll;
                cout<<"\n the student name: "<<name;
                cout<<"\n the student coty: "<<city;
        }
};
class marks: public student
{
        int sub1;
        int sub2;
        int sub3;
        int per;
        public:

    void input()
        {
                getdata();
                cout<<"\n enter the marks1: ";
                cin>>sub1;
                cout<<"\n enter the marks2: ";
                cin>>sub2;
                cout<<"\n enter the marks3: ";
                cin>>sub3;
        }
        void output()
        {
                putdata();
                cout<<"\n marks1: "<<sub1;
                cout<<"\n marks2: "<<sub2;
                cout<<"\n marks3: "<<sub3<<"\n";
        }
        void calculate ()
        {
                per= (sub1+sub2+sub3)/3;
                cout<<"\n total percentage :: "<<per<<"\n";
        }
};

int main()
{
        marks m1;
        int ch;
        int count=0;
        do
        {
                cout<<"\n1.input data";
                cout<<"\n2.output data";
                cout<<"\n3.Calculate percentage";
                cout<<"\n4.exit\n";
                cout<<"\nEnter the choice :: ";
                cin>>ch;
                switch (ch)
                {
        case 1:
                        m1.input();
                        count++;
                        break;

        case 2:
                        m1.output();
                        break;

        case 3:
                        m1.calculate();
                        break;
                }
        } while (ch!=4);
}

OUTPUT : :


/*  C++ Program display Student Marksheet using Multiple inheritance  */

  welcome in the student information system

1.input data
2.output data
3.Calculate percentage
4.exit

Enter the choice :: 1

 enter the student roll no.  1

 enter the student name  Codez

 enter ther student address  India

 enter the student city  Chandigarh

 enter the marks1: 80

 enter the marks2: 90

 enter the marks3: 70

1.input data
2.output data
3.Calculate percentage
4.exit

Enter the choice :: 2

 the student roll no: 1
 the student name: Codez
 the student coty: Chandigarh
 marks1: 80
 marks2: 90
 marks3: 70


1.input data
2.output data
3.Calculate percentage
4.exit

Enter the choice :: 3

 total percentage :: 80


1.input data
2.output data
3.Calculate percentage
4.exit

Enter the choice :: 4

Process returned 0

Above is the source code and output for C++ Program display Student Marksheet using Multiple inheritance which is successfully compiled and run on Windows System to produce desired output.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Program to find Area of Rectangle using inheri... >>
<< C++ Program to demonstrate an Example of Hybrid In...