NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

/*
Consider an example of declaring an examination result. Design three
classes: Student, Exam and Result.
-> The Student class has data members such as those representing Roll No.,
Name,etc.
-> Create a class Exam by inheriting the Student class. The Exam class adds
data members representing the marks scored in six subjects.
-> Derive class Result from Exam class and it has own data members such as
total_marks.
Write an interactive program to model this relationship. What type of
inheritance this model belongs to.
*/

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

class Student
{
char rollno[20],name[50],branch[20];
public:
void set_student()
{
cout<<"Enter Student Name: ";
gets(name);

cout<<"Enter Roll No.: ";
gets(rollno);

cout<<"Enter Branch: ";
gets(branch);
}

char *getname()
{
return name;
}

char *getrollno()
{
return rollno;
}

char *getbranch()
{
return branch;
}
};

class Exam : public Student
{
int phy,chem,bio,maths,eng,hin;
public:
void setmarks()
{
cout<<"Enter Physics marks: ";
cin>>phy;

cout<<"Enter Chemistry marks: ";
cin>>chem;

cout<<"Enter Biology marks: ";
cin>>bio;

cout<<"Enter Mathematics marks: ";
cin>>maths;

cout<<"Enter English marks: ";
cin>>eng;

cout<<"Enter Hindi marks: ";
cin>>hin;

}
int getphy()
{
return phy;
}

int getchem()
{
return chem;
}

int getbio()
{
return bio;
}

int getmaths()
{
return maths;
}

int geteng()
{
return eng;
}

int gethin()
{
return hin;
}
};

class Result : public Exam
{
int total_marks,p,c,b,m,e,h;
float percentage;
public:
void result()
{
cout<<"Enter Student Details:nn";
set_student();
cout<<"nnEnter Marks Details:nn";
setmarks();
p = getphy();
c = getchem();
b = getbio();
m = getmaths();
e = geteng();
h = gethin();
total_marks = p+c+b+m+e+h;
percentage = total_marks/6;
}

void display()
{
cout<<"Student Details:nn";
cout<<"Student Name: "<<getname()<<endl;
cout<<"Roll Number: "<<getrollno()<<endl;
cout<<"Branch: "<<getbranch()<<endl;

cout<<"nMarks: n"<<endl;
cout<<"Physics: "<<p<<endl;
cout<<"Chemistry: "<<c<<endl;
cout<<"Biology: "<<b<<endl;
cout<<"Mathematics: "<<m<<endl;
cout<<"English: "<<e<<endl;
cout<<"Hindi: "<<h<<endl;

cout<<"Total: "<<total_marks<<endl;
cout<<"Percentage: "<<percentage<<endl;

}
};

void main()
{
clrscr();
Result R;

R.result();
clrscr();

R.display();

getch();
}
     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.