ALGORITHM:
STEP 1: Start the program.
STEP 2: Declare the class name as fn with data members and member functions.
STEP 3: Read the choice from the user.
STEP 4: Choice=1 then go to the step 5.
STEP 5: The function area() to find area of circle with one integer argument.
STEP 6: Choice=2 then go to the step 7.
STEP 7: The function area() to find area of rectangle with two integer argument.
STEP 8: Choice=3 then go to the step 9.
STEP 9: The function area() to find area of triangle with three arguments, two as Integer and one as float.
STEP 10: Choice=4 then stop the program.
PROGRAM:
08 | void area(int); //circle |
09 | void area(int,int); //rectangle |
10 | void area(float ,int,int); //triangle |
15 | cout<<"Area of Circle:"<<pi*a*a; |
17 | void fn::area(int a,int b) |
19 | cout<<"Area of rectangle:"<<a*b; |
21 | void fn::area(float t,int a,int b) |
23 | cout<<"Area of triangle:"<<t*a*b; |
32 | cout<<"\n\t\tFunction Overloading"; |
33 | cout<<"\n1.Area of Circle\n2.Area of Rectangle\n3.Area of Triangle\n4.Exit\n:”; |
34 | cout<<”Enter your Choice:"; |
40 | cout<<"Enter Radious of the Circle:"; |
45 | cout<<"Enter Sides of the Rectangle:"; |
50 | cout<<"Enter Sides of the Triangle:"; |
Output:
Function Overloading
1. Area of Circle
2. Area of Rectangle
3. Area of Triangle
4. Exit
Enter Your Choice: 2
Enter the Sides of the Rectangle: 5 5
Area of Rectangle is: 25
1. Area of Circle
2. Area of Rectangle
3. Area of Triangle
4. Exit
Enter Your Choice: 4
Tidak ada komentar:
Posting Komentar