/*Program for above Hierachy where Employee id Base class and Programmer and manager are child class. Make display function virtual which is common for all the three classes*/ /**************************Experiment 16****************************/ #include<iostream.h> #include<conio.h> class Employee { private: char name[20]; float sal; public: void accept() { cout<<"\n\n\t\tEnter the Emplyee Name : "; cin>>name; cout<<"\n\n\t\tEnter the salary : "; cin>>sal; Employee Manager Programmer
Pratik Bakane C++ programs...............This are programs desingedby sy diploma student from Governement Polytecnic Thane.....programsare very easy alongwith coding andscreen shot of the output
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
/*Program for above Hierachy where Employee id Base class and Programmer and manager are child class. Make display function virtual which is common for all the three classes*/
cout<<"\n\n\t\tThe sum of ten Integers numbers : "<<x;
cout<<"\n\n\t\tThe sum of five floating numbers : "<<y;
getch();
}
OUTPUT:
/*Program to declare a class student having data members as roll_no and percentage. Using ‘this’ pointer invoke member functions to accept and display this data for one object of the class.*/
#include<iostream.h>
#include<conio.h>
#include<math.h>
class student
{
private:
int r_no,per;
public:
void accept()
{
cout<<"\n\n\t\tEnter the Roll Number : ";
cin>>r_no;
cout<<"\n\n\t\tEnter the Percentage : ";
cin>>per;
}
void display()
{
cout<<"\n\n\t\tRoll Number is : ";
cout<<this->r_no;
cout<<"\n\n\t\tPercentage is : ";
cout<<this->per;
}
};
void main()
{
clrscr();
student s1;
s1.accept();
s1.display();
getch();
}
OUTPUT
/************************Page Number 61***************/
#include<iostream.h>
#include<conio.h>
#include<math.h>
class example
{
int a,b;
public:
example(int x,int y)
{
a=x;
b=y;
cout<<"\n\n\t\tI am Constructor ";
}
void display()
{
cout<<"\n\n\t\tValues : "<<a<<"\t"<<b;
}
};
void main()
{
clrscr();
example obj(10,20);
obj.display();
getch();
}
OUTPUT:
/*Program to define a class salary which will contain member variable basic,ta,da,hra. Devlop a program using constructor with default value(s) for da and hra and calculate the salary of employee*/