0% found this document useful (0 votes)
7 views4 pages

Over

The document discusses function overloading and enumeration in C++. It defines multiple functions called volume() that take different parameters and return types to calculate the volume of a cube, cylinder and cuboid. It also defines an enumerated data type called days to represent the days of the week, and uses a switch statement to output the day name based on the user's input selection.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Over

The document discusses function overloading and enumeration in C++. It defines multiple functions called volume() that take different parameters and return types to calculate the volume of a cube, cylinder and cuboid. It also defines an enumerated data type called days to represent the days of the week, and uses a switch statement to output the day name based on the user's input selection.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4

Function overloding

#include<iostream.h>
#include<conio.h>
int volume(int);
double volume(double,int);
long volume(long,int,int);
void main()
{
clrscr();
long l;
double r;
int b,h,s;
int i;
do
{
cout<<"\n1.Cube\n2.Cylinder\n3.Cuboid\n";
cout<<"enter your choice";
cin>>i;
switch(i)
{
case 1:
{
cout<<"\nenter the side: ";
cin>>s;
cout<<"\nResult"<<volume(s);
break;
}
case 2:
{
cout<<"\nenter the radius";
cin>>r;
cout<<"enter the height of the cylinder ";
cin>>h;
cout<<"\nResult"<<volume(r,h);
break;
}
case 3:
{
cout<<"\nenter the length of cuboid";
cin>>l;
cout<<"enter the breadth of cuboid";
cin>>b;
cout<<"enter the height of cuboid ";
cin>>h;
cout<<"\nResult"<<volume(l,b,h);

break;
}
default:
cout<<"wrong choce";
break;
}
}while(i<=3);
}
int volume(int s)
{
return(s*s*s);
}
double volume(double r,int h)
{
return(3.14*r*r*h);
}
long volume(long l,int b,int h)
{
return(l*b*h);
}

Enumeration
#include<iostream.h>
#include<conio.h>
enum days
{
Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
};
void main()
{
clrscr();
int t;
do
{
cout<<"\n ------------------------------------------------------------";
cout<<"\n\t\t\t ENUMURATION";
cout<<"\n ------------------------------------------------------------";
cout<<"\n1.sun\n2.mon\n3.tues\n4.wed\n5.thur\n6.fri\n7.sat";
cout<<"\nEnter your choice";
cin>>t;
cout<<"\n\n\n OUTPUT :"<<"\n";
switch(t)
{
case 1:
cout<<"\t\t\tITS Sunday "<<endl;
break;
case 2:
cout<<"\t\t\tITS MONDAY "<<endl;
break;
case 3:
cout<<"\t\t\tITS tuesday "<<endl;
break;
case 4:
cout<<"\t\t\tITS wednesday "<<endl;
break;
case 5:
cout<<"\t\t\tITS thursday "<<endl;
break;
case 6:
cout<<"\t\t\tITS friday "<<endl;
break;
case 7:
cout<<"\t\t\tITS saturday "<<endl;
break;
default:
cout<<"wrong choice"<<endl;
}

}while(t<8);
getch();
}

You might also like