Subscribe to Feeds

Send Your COMPLETED Projects To georgepj@hotmail.com

We'll Publish It With Your Name :-)

Programs Can Also Be Downloaded From The Folders Below....[Or Scroll Down]

Area of Triangle ( Function Overloading )

Click Here To Download C++ File Of This Program

 //PROGRAM (c)c4cpp.co.nr 
#include<iostream.h>
#include<conio.h>
#include<process.h>
#include<math.h>
//function 1
void area(float r)
{float area_c;
area_c=(3.14*r*r);
cout<<"Area of the circle="<<area_c<<endl;
}
//function 2
void area(int l,int h)
{float area_r;
area_r=l*h;
cout<<"Area of the rectangle = "<<area_r<<endl;
}
//function 3
void area(float a,float b,float c)
{float s,area_t ;
s=(a+b+c)/2;
area_t=pow((s*(s-a)*(s-b)*(s-c)),0.5);
cout<<"Area of the triangle = "<<area_t<<endl;
}
void main()
{
clrscr();
int ch;
float r,a,b,c,l,h;
cout<<"1.Area of circle"<<endl<<"2.Area of rectangle"<<endl;cout<<"3.Area of triangle"<<endl<<"4.Exit"<<endl;
X:
cout<<"Enter the choice"<<endl;
cin>>ch;
switch(ch)
{
case 1:cout<<"Enter the radius of the circle"<<endl;
cin>>r;
void area (float);
area(r);
goto X;
case 2:cout<<"Enter the sides of rectangle"<<endl;
cin>>l>>h;
void area (float,float);
area (l,h);
goto X;
case 3:cout<<"Enter the sides of triangle"<<endl;
cin>>a>>b>>c;
void area (float,float,float);
area (a,b,c);
goto X;
case 4:exit(0);
default:cout<<"Wrong Choice"<<endl;
goto X;}
getch();}

No comments: