Name : Yashi Somani
Enrollment No. : EN19EL301150
Class/Section : CSE-C
Program -1
Aim : Program to understand cout and cin.
Code :
#include<iostream>
using namespace std ;
int main()
int x, y;
int sum;
cout << "Type a number: "; //Object of input stream
cin >> x; //Object of output stream
cout << "Type another number: ";
cin >> y;
sum = x + y;
cout << "Sum is: " << sum;
return 0;
}
Output :
Program -2
Aim : Program to find size of a variable
Code :
#include<iostream>
using namespace std;
int main()
{
int integerType;
char charType;
float floatType;
double doubleType;
cout << "Size of int is: " <<
sizeof(integerType) <<"\n";
cout << "Size of char is: " <<
sizeof(charType) <<"\n";
cout << "Size of float is: " <<
sizeof(floatType) <<"\n";
cout << "Size of double is: " <<
sizeof(doubleType) <<"\n";
return 0;
}
Output:
Program -3
Aim : C++ Program to reverse an integer
Code :
#include<iostream>
Using namespace std;
int main()
{
int n, reverse=0, rem;
cout<<"Enter a number: ";
cin>>n;
while(n!=0)
{
rem=n%10;
reverse=reverse*10+rem;
n/=10;
}
cout<<"Reversed Number: "<<reverse<<endl;
return 0;
Output:
Program -4
Aim : C++ Program to generate all the prime no. between 1 to n,where n is the
value by user.
Code :
#include<iostream>
using namespace std;
int main()
int num, i, upto;
cout << "Find prime numbers upto : "; // Input from user
cin >> upto;
cout << endl << "All prime numbers upto " << upto << " are : " << endl;
for(num = 2; num <= upto; num++)
for(i = 2; i <= (num / 2); i++)
if(num % i == 0)
i = num;
break;
if(i != num)
cout << num << " ";
}
return 0;
}
Output:
Program -5
Aim : C++ Program to find both the largest and smallest number in a list of
integers.
Code :
#include<iostream>
using namespace std;
int main ()
int arr[10], n, i, max, min;
cout << "Enter the size of the array : ";
cin >> n;
cout << "Enter the elements of the array : ";
for (i = 0; i < n; i++)
cin >> arr[i];
max = arr[0];
for (i = 0; i < n; i++)
if (max < arr[i])
max = arr[i];
min = arr[0];
for (i = 0; i < n; i++)
if (min > arr[i])
min = arr[i];
cout << "Largest element : " << max;
cout << "Smallest element : " << min;
return 0;
OUTPUT:
Program -6
Aim : Program for calculating average of two numbers
Code :
#include <iostream>
using namespace std;
int main()
int x,y,sum;
float average;
cout << "Enter 2 integers : " << endl;
cin>>x>>y;
sum=x+y;
average=sum/2;
cout << "The sum of " << x << " and " << y << " is " << sum << "." << endl;
cout << "The average of " << x << " and " << y << " is " << average << "." << endl;
OUTPUT :
Program -7
Aim : Program for swapping of two numbers without using third variable.
Code :
#include <iostream>
using namespace std;
int main()
int a=5, b=10;
cout<<"Before swap a= "<<a<<" b= "<<b<<endl;
a=a*b; //a=50 (5*10)
b=a/b; //b=5 (50/10)
a=a/b; //a=10 (50/5)
cout<<"After swap a= "<<a<<" b= "<<b<<endl;
return 0;
OUTPUT :
Program -8
Aim : Program to check greater number without using if-else .
Code :
#include <iostream>
using namespace std;
// Function to find the largest number
int largestNum(int a, int b)
return a * (bool)(a / b) + b * (bool)(b / a);
// Drivers code
int main()
int a = 22, b = 1231;
cout << largestNum(a, b);
return 0;
OUTPUT :
Program -9
Aim : Program to check whether the number is prime or not.
Code :
#include <iostream>
using namespace std;
int main()
int n, i, m=0, flag=0;
cout << "Enter the Number to check Prime: ";
cin >> n;
m=n/2;
for(i = 2; i <= m; i++)
{
if(n % i == 0)
cout<<"Number is not Prime."<<endl;
flag=1;
break;
if (flag==0)
cout << "Number is Prime."<<endl;
return 0;
OUTPUT :
Program -10
Aim : Program for switch case having :
1 .Factorial of a number.
Code :
#include <iostream>
using namespace std;
int main()
int i,fact=1,number;
cout<<"Enter any Number: ";
cin>>number;
for(i=1;i<=number;i++){
fact=fact*i;
cout<<"Factorial of " <<number<<" is: "<<fact<<endl;
return 0;
OUTPUT :
2.Even and odd number
Code :
#include <iostream>
using namespace std;
int main()
int num1=452;
int num2=591;
switch(num1%2){ //this will return either 0 or 1
case 0:
cout<<num1<<" is a even number";
break;
case 1:
cout<<num2<<" is a odd number";
}
return 0;
OUTPUT :
3.Leap year or not
Code :
#include<iostream>
using namespace std;
int year;
int main()
{
cout << "Please enter the current year: ";
cin >> year;
switch (year % 4)
case 0:
if (year % 100 == 0)
cout << "\"Century\" years aren't leap years.";
if (year % 400 == 0)
cout << "..unless divisible by 400.\n";
cout << year << "'s a leap year!" << endl;
else
cout << " " << year << " isn't a leap year." << endl;
else
cout << year << " is a leap year!" << endl;
break;
case 3:
cout << "Next year is a leap year. "; // Fall through...
default:
cout << year << " isn't a leap year." << endl;
break;
OUTPUT :
4.Exit
Code :
#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
char ch;
while(true)
cout<<"l.print l "<<endl<<"c.print c "<<endl<<"q. exit"<<endl;
cout<<"enter choice"<<endl;
cin>>ch;
switch(ch)
case 'l':
cout<<"You have typed l "<<endl;
break;
case 'c':
cout<<"You have typed c"<<endl;
break;
case 'q':
cout<<"Exit ..." <<endl;
exit(0);
default:
cout<<"Wrong choice "<<endl;
return 0;
}
OUTPUT :
Program -11
Aim : Program for implementing classes and objects.
Code :
#include <iostream>
#include <string>
using namespace std;
class MyClass { // The class
public: // Access specifier
int myNum; // Attribute (int variable)
string myString; // Attribute (string variable)
};
int main() {
MyClass myObj; // Create an object of MyClass
// Access attributes and set values
myObj.myNum = 15;
myObj.myString = "Some text";
// Print values
cout << myObj.myNum << "\n";
cout << myObj.myString;
return 0;
OUTPUT :
Program -12
Aim : Program for implementing member function outside the class.
Code :
#include <iostream>
using namespace std;
class Box {
public:
double length; // Length of a box
double breadth; // Breadth of a box
double height; // Height of a box
// Member functions declaration
double getVolume(void);
void setLength( double len );
void setBreadth( double bre );
void setHeight( double hei );
};
// Member functions definitions
double Box::getVolume(void) {
return length * breadth * height;
}
void Box::setLength( double len ) {
length = len;
void Box::setBreadth( double bre ) {
breadth = bre;
void Box::setHeight( double hei ) {
height = hei;
// Main function for the program
int main() {
Box Box1; // Declare Box1 of type Box
Box Box2; // Declare Box2 of type Box
double volume = 0.0; // Store the volume of a box here
// box 1 specification
Box1.setLength(6.0);
Box1.setBreadth(7.0);
Box1.setHeight(5.0);
// box 2 specification
Box2.setLength(12.0);
Box2.setBreadth(13.0);
Box2.setHeight(10.0);
// volume of box 1
volume = Box1.getVolume();
cout << "Volume of Box1 : " << volume <<endl;
// volume of box 2
volume = Box2.getVolume();
cout << "Volume of Box2 : " << volume <<endl;
return 0;
OUTPUT :
Program -13
Aim : Program for implementing single dimensional array .
Code :
#include<iostream>
using namespace std;
int main()
int i;
int value[6] = {5,10,15,20,25,30}
cout<<"Single Dimensional Array \n”
for (i=0;i<6;i++)
cout<<"Position : "<<i<<" , Value : "<< value[i]<<" \n";
return 0;
OUTPUT :
Program -14
Aim : Program for implementing two dimensional array .
Code :
#include <iostream>
using namespace std;
int main()
int r, c, a[100][100], b[100][100], sum[100][100], i, j;
cout << "Enter number of rows (between 1 and 100): ";
cin >> r;
cout << "Enter number of columns (between 1 and 100): ";
cin >> c;
cout << endl << "Enter elements of 1st matrix: " << endl;
// Storing elements of first matrix entered by user.
for(i = 0; i < r; ++i)
for(j = 0; j < c; ++j)
cout << "Enter element a" << i + 1 << j + 1 << " : ";
cin >> a[i][j];
// Storing elements of second matrix entered by user.
cout << endl << "Enter elements of 2nd matrix: " << endl;
for(i = 0; i < r; ++i)
for(j = 0; j < c; ++j)
cout << "Enter element b" << i + 1 << j + 1 << " : ";
cin >> b[i][j];
// Adding Two matrices
for(i = 0; i < r; ++i)
for(j = 0; j < c; ++j)
sum[i][j] = a[i][j] + b[i][j];
// Displaying the resultant sum matrix.
cout << endl << "Sum of two matrix is: " << endl;
for(i = 0; i < r; ++i)
for(j = 0; j < c; ++j)
cout << sum[i][j] << " ";
if(j == c - 1)
cout << endl;
return 0;
OUTPUT :
Program -15
Aim : Program for implementing static member function inside a class.
Code :
#include <iostream>
using namespace std;
class Demo
private:
//static data members
static int X;
static int Y;
public:
//static member function
static void Print()
cout <<"Value of X: " << X << endl;
cout <<"Value of Y: " << Y << endl;
};
//static data members initializations
int Demo :: X =10;
int Demo :: Y =20;
int main()
Demo OB;
//accessing class name with object name
cout<<"Printing through object name:"<<endl;
OB.Print();
//accessing class name with class name
cout<<"Printing through class name:"<<endl;
Demo::Print();
return 0;
OUTPUT :
Program -16
Aim : Program for implementing static data member inside the class.
Code :
#include <iostream>
#include<string.h>
using namespace std;
class Student {
private:
int rollNo;
char name[10];
int marks;
public:
static int objectCount;
Student() {
objectCount++;
void getdata() {
cout << "Enter roll number: "<<endl;
cin >> rollNo;
cout << "Enter name: "<<endl;
cin >> name;
cout << "Enter marks: "<<endl;
cin >> marks;
void putdata() {
cout<<"Roll Number = "<< rollNo <<endl;
cout<<"Name = "<< name <<endl;
cout<<"Marks = "<< marks <<endl;
cout<<endl;
};
int Student::objectCount = 0;
int main(void) {
Student s1;
s1.getdata();
s1.putdata();
Student s2;
s2.getdata();
s2.putdata();
Student s3;
s3.getdata();
s3.putdata();
cout << "Total objects created = " << Student::objectCount << endl;
return 0;
OUTPUT :
Program -17
Aim : Program for implementing array of objects.
Code :
#include <iostream>
using namespace std;
class Rectangle
public:
int length;
int breadth;
Rectangle( int l, int b )
length = l;
breadth = b;
int printArea()
return length * breadth;
};
int main()
Rectangle rt1( 7, 4 );
Rectangle rt2( 4, 5 );
cout << "Area of first rectangle " << rt1.printArea() << endl;
cout << "Area of second rectangle " << rt2.printArea() << endl;
return 0;
OUTPUT :
Program -18
Aim : Program for implementing function prototype.
Code :
#include<iostream>
using namespace std;
//Create a class
class MyClass{
public : // Access Specifier
void myFunction(){ // Function Declaration
cout<< “Hello World”; // Function Defination
}
};
int main() {
MyClassmyObj; // Create an object
myObj.myFunction ; // Call a function
return 0;
}
OUTPUT :
Program -19
Aim : Program for implementing Call by value
Code :
#include<iostream>
using namespace std;
//Function Declaration
void swap(int x , int y);
int main() {
int a=100;// Variable Declaration
int b=200;
cout<<“Before swap, value of a :” << a<<endl;
cout<<”Before swap, value of b :” <<b<<endl<<endl;
swap(a,b);// Calling a function to swap the values
cout<<”After swap, value of a:”<<a<<endl;
cout<<”After swap, value of b:”<<b<<endl<<endl;
return 0;
}
void swap(int x, int y){
int temp;
cout<<”within swap function, before swap operation value of x:”<<x<<endl;
cout<<”within swap function, before swap operation value of y:”<<y<<endl<<endl;
temp=x;
x=y;
y=temp;
cout<<”with in swap function,after swap operation value of x:”<<x<<endl;
cout<<with in swap function,after swap operation value of y:”<<y<<endl<<endl;
return ;
}
OUTPUT :
Program -20
Aim : Program for the implementation of call by reference
Code :
#include<iostream>
Using namespace std;
void swap(int *x, int *y)
{
int swap;
swap = *x;
*x = *y;
*y = swap ;
}
int main()
{
int x = 500, y = 100;
swap(&x,&y);// passing value to function
cout<< “value of x is :” <<x <<endl;
cout<< “value of y is :” <<y <<endl;
return 0 ;
}
OUTPUT :
Program -21
Aim : Program for call by address
Code :
#include<iostream>
using namespace std;
//a stores the address of x
void increment(int *a){
(*a)++;
cout<< “value in function increment: << *a <<endl;
}
int main()
{
int x = 5;
increment (&x);//passing the address of x
cout<< “value in function main:”<<x<<endl;
return 0;
}
OUTPUT :
Program -24
Aim : Program for implementing inline functions using class
Code :
#include<iostream>
using namespace std;
inline void displayNum(int num)
{
cout<<num<<endl;
}
int main()
{
//first function call
displayNum(5);
//second function call
displayNum(8);
//third function call
displayNum(666);
return 0;
OUTPUT :
Program -25
Aim : Program for implementing addition of two numbers with the help of
multiple inheritance.
Code :
#include <iostream
using namespace std;
class input1
public:
int a;
void getinput1()
cout<<"\nEnter any number\n";
cin>>a;
}
};
class input2
public:
int b;
void getinput2()
cout<< "\nEnter any number\n";
cin>>b;
};
class addition:public input1,public input2
public:
int c,d,e;
void sum()
c=a+b;
cout<< "\nSum of two numbers is"<<c;
void product()
{
d=a*b;
cout<<"\nproduct of two numbers is"<<d;
void divide()
e=a/b;
cout<<"\ndivision of two numbers is"<<e;
};
int main()
addition a1;
a1.getinput1();
a1.getinput2();
a1.sum();
a1.product();
return 0;
OUTPUT :
Program -26
Aim : Program for implementing objects as functional arguments.
Code :
#include<iostream>
using namespace std;
class Time
int hour;
int minute;
public :
void total(Time); // function declaration
};
void Time :: total(Time tmp) // Receive object as argument
int hr, min;
min = minute + tmp.minute;
hr = hour + tmp.hour + min/60;
min = min % 60;
cout << hr <<"Hours and "<< min << "Minutes"<<endl ;
int main( )
Time theory, practical;
theory.total(practical); // Passing object as argument
OUTPUT :
Program -27
Aim : Program for implementing a default constructor.
Code :
#include <iostream>
using namespace std;
class DemoDC {
private:
int num1, num2 ;
public:
DemoDC() {
num1 = 10;
num2 = 20;
}
void display() {
cout<<"num1 = "<< num1 <<endl;
cout<<"num2 = "<< num2 <<endl;
};
int main() {
DemoDC obj;
obj.display();
return 0;
OUTPUT :
Program -28
Aim : Program for implementing paramerterized constructor.
Code :
#include <iostream>
using namespace std;
class ParamA {
private:
int b, c;
public:
ParamA (int b1, int c1)
b = b1;
c = c1;
int getX ()
return b;
int getY ()
return c;
};
int main ()
ParamA p1(10, 15);
cout << "p1.b = " << p1. getX() << ", p1.c = " << p1.getY();
return 0;
OUTPUT :
Program -29
Aim : Program for implementing copy constructor.
Code :
#include <iostream>
using namespace std;
class A
public:
int x;
A(int a) // parameterized constructor.
x=a;
A(A &i) // copy constructor
x = i.x;
};
int main()
A a1(20); // Calling the parameterized constructor.
A a2(a1); // Calling the copy constructor.
cout<<a2.x;
return 0;
OUTPUT :
Program -30
Aim : Program for implementing constructor overloading.
Code :
#include <iostream>
using namespace std;
class Person {
private:
int age;
public:
// 1. Constructor with no arguments
Person() {
age = 20;
}
// 2. Constructor with an argument
Person(int a) {
age = a;
int getAge() {
return age;
};
int main() {
Person person1, person2(45);
cout << "Person1 Age = " << person1.getAge() << endl;
cout << "Person2 Age = " << person2.getAge() << endl;
return 0;
OUTPUT :
Program -31
Aim : Program for implementing destructor overloading.
Code :
#include<iostream>
using namespace std;
class demo
private:
int a;
float b;
public:
demo();
};
demo::demo()
{
cout<<"Enter the value of a and b :";
cin>>a>>b;
cout<<"a = "<<a<<endl;
cout<<"b = "<<b<<endl;
int main()
demo d1;
OUTPUT :
Program -32
Aim : Program for implementing local class/objects in c++.
Code :
#include<iostream>
using namespace std;
void fun()
class Test // local to fun
public:
// Fine as the method is defined inside the local class
void method() {
cout << "Local Class method() called";
};
Test t;
t.method();
int main()
fun();
return 0;
}
OUTPUT :
Program -38
Aim : Program to implement single level inheritance c++.
Code :
#include <iostream>
using namespace std;
class base //single base class
public:
int x;
void getdata()
{
cout << "Enter the value of x = "; cin >> x;
};
class derive : public base //single derived class
private:
int y;
public:
void readdata()
cout << "Enter the value of y = "; cin >> y;
void product()
cout << "Product = " << x * y;
};
int main()
derive a; //object of derived class
a.getdata();
a.readdata();
a.product();
return 0;
} //end of program
OUTPUT :
Program -39
Aim : Program to implement Multilevel inheritance c++.
Code :
#include <iostream>
using namespace std;
class A
public:
void display()
{
cout<<"Base class content.";
};
class B : public A
};
class C : public B
};
int main()
C obj;
obj.display();
return 0;
OUTPUT :
Program -40
Aim : Program to implement Multiple inheritance c++.
Code :
#include <iostream>
using namespace std;
class Mammal {
public:
Mammal()
cout << "Mammals can give direct birth." << endl;
};
class WingedAnimal {
public:
WingedAnimal()
cout << "Winged animal can flap." << endl;
};
class Bat: public Mammal, public WingedAnimal {
};
int main()
Bat b1;
return 0;
OUTPUT :
Program -41
Aim : Program to implement Hierarchical inheritance c++.
Code :
#include <iostream>
using namespace std;
class A //single base class
public:
int x, y;
void getdata()
cout << "\nEnter value of x and y:\n"; cin >> x >> y;
};
class B : public A //B is derived from class base
public:
void product()
cout << "\nProduct= " << x * y;
};
class C : public A //C is also derived from class base
public:
void sum()
cout << "\nSum= " << x + y;
};
int main()
B obj1; //object of derived class B
C obj2; //object of derived class C
obj1.getdata();
obj1.product();
obj2.getdata();
obj2.sum();
return 0;
} //end of program
OUTPUT :
Program -42
Aim : Program for implementing hybrid inheritance.
Code :
#include<iostream>
#include<string>
using namespace std;
class student
public:
student()
{
cout<<"Hello I am a student"<<endl;
string collegeName="Medicaps University";
};
class student1:public student
public:
student1()
cout<<"Student of CSE-C"<<endl;
string name="Yashi";
};
class student2
public:
void display()
cout<<"Rollno 50"<<endl;
};
class student3:public student2
};
class student4:public student2
};
int main()
student1 obj;
student2 obj1;
cout<<"Name:"<<obj.name<<endl;
cout<<"collegeName:"<<obj.collegeName<<endl;
obj1.display();
return 0;
OUTPUT :
Program -43
Aim : Program for implementing constructor and destructor in inheritance.
Code :
#include <iostream>
using namespace std;
// base class
class Parent
public:
// base class constructor
Parent()
cout << "Inside base class" << endl;
}
};
// sub class
class Child : public Parent
public:
//sub class constructor
Child()
cout << "Inside sub class" << endl;
};
// main function
int main() {
// creating object of sub class
Child obj;
return 0;
OUTPUT :
Program -44
Aim : Program for implementing function overloading.
Code :
#include <iostream>
using namespace std;
class over
public:
int get(int,int,int);
float get(float,float,float);
float get(int,int,float);
};
int over::get(int a,int b,int c )
{
if(a>b&&a>c)
return a;
else
if(b>a&&b>c)
return b;
else
return c;
float over::get(float a,float b,float c)
if(a>b&&b>c)
return a;
else
if(b>a&&b>c)
return b;
else
return c;
float over::get(int a,int b,float c)
{
if(a>b&&a>c)
return a;
else
if(b>a&&b>c)
return b;
else
return c;
int main()
int n1,n2,n3,t;
float x,y,z;
over obj;
cout<< "\nEnter three integer number:";
cin>>n1>>n2>>n3;
t=obj.get(n1,n2,n3);
cout<< "\nMaximum number is:"<<t;
cout<<"\nEnter three float number:";
cin>>x>>y>>z;
float temp=obj.get(x,y,z);
cout<<"\nMaximum number is"<<temp;
return 0;
}
OUTPUT :
Program -45
Aim : Program for unary operator overloading.
Code :
#include <iostream>
using namespace std;
class demo
public:
int a,b;
demo()
{}
demo(int p,int q)
a=p;
b=q;
void show()
cout<<"\nvalue of a="<<a;
cout<<"/nvalue of b="<<b;
demo operator +(demo dx)
class demo dp;
dp.a=a+dx.a;
dp.b=b+dx.b;
return dp;
void operator ++()
cout<<"\nPre-increment called ";
a=++a;
b=++b;
void operator ++(int x)
cout<<"\nPost increment called ";
a=a++;
b=b++;
};
int main()
demo d1(1,2),d2(3,4),d3;
d3=d1+d2;
d3.show();
++d3;
d3.show();
d3++;
d3.show();
return 0;
}
OUTPUT :
Program -47
Aim : Program for implementing dynamic polymorphism.
Code :
#include <iostream>
using namespace std;
class A {
public:
void disp(){
cout<<"Super Class Function"<<endl;
};
class B: public A{
public:
void disp(){
cout<<"Sub Class Function";
};
int main() {
//Parent class object
A obj;
obj.disp();
//Child class object
B obj2;
obj2.disp();
return 0;
OUTPUT :
Program -48
Aim : Program for implementing pure virtual function.
Code :
#include <iostream>
using namespace std;
class gshape
public:
float ar,pr;
virtual void showar()=0;
virtual void showpr()=0;
};
class circle:public gshape
public:
void getarea(float r)
ar=3.14*r*r;
void getperi(float r)
pr=2*3.14*r;
void showar()
{
cout<<"\nArea of circle is "<<ar;
void showpr()
cout<<"\nPerimeter of a circle is "<<pr;
};
class Rectangle:public gshape
public:
void getarea(float l, float b)
ar=l*b;
void getperi(float l,float b)
pr=2*l+2*b;
void showar()
cout<<"\nArea of rectangle is "<<ar<<endl;
}
void showpr()
cout<<"\nPerimeter of a rectangle is "<<pr<<endl;
};
int main(void)
gshape *gptr;
circle c;
gptr=&c;
c.getarea(2);
c.getperi(3);
gptr->showar();
gptr->showpr();
Rectangle r;
gptr=&r;
r.getarea(6,7);
r.getperi(2,2);
gptr->showar();
gptr->showpr();
return 0;
}
OUTPUT :
Program -49
Aim : Program for implementing addition of two numbers with the help of
multilevel inheritance.
Code :
#include <iostream>
#include<cmath>
using namespace std;
class input
{
public:
int a,b;
void getinput()
cout<<"\nEnter any two numbers\n";
cin>>a>>b;
};
class addition:public input
public:
int c;
void sum()
c=a+b;
cout<<"\nSum of two numbers is"<<c;
};
class square:public addition
public:
int s;
void sqr()
{
s=c*c;
cout<<"\nSquare of addition of two numbers is"<<s;
};
class squareroot:public square
public:
int r;
void root()
r=sqrt(s);
cout<<"\nsquae root of"<<r;
};
int main()
squareroot a1;
a1.getinput();
a1.sum();
a1.sqr();
a1.root();
return 0;
}
OUTPUT :
Program -50
Aim : Program for implementing function overloading (polymorphism).
#include <iostream>
using namespace std;
class over
public:
int get(int,int,int);
float get(float,float,float);
float get(int,int,float);
};
int over::get(int a,int b,int c )
if(a>b&&a>c)
return a;
else
if(b>a&&b>c)
return b;
else
return c;
float over::get(float a,float b,float c)
if(a>b&&b>c)
return a;
else
if(b>a&&b>c)
return b;
else
return c;
float over::get(int a,int b,float c)
if(a>b&&a>c)
return a;
else
if(b>a&&b>c)
return b;
else
return c;
int main()
int n1,n2,n3,t;
float x,y,z;
over obj;
cout<< "\nEnter three integer number:";
cin>>n1>>n2>>n3;
t=obj.get(n1,n2,n3);
cout<< "\nMaximum number is:"<<t;
cout<<"\nEnter three float number:";
cin>>x>>y>>z;
float temp=obj.get(x,y,z);
cout<<"\nMaximum number is"<<temp;
return 0;
OUTPUT :