Sunday, 15 November 2015

C++ To Calculate Area Of Circle, Rectangle And Triangle Using Switch Case

Problem:- Write A C++  To Calculate Area Of Circle Rectangle And Triangle Using Switch Case or C++ Program to Compute Area of Shapes using Switch Case or c++ program to find area of circle using functions or c++ program to find area of rectangle and circle using class and object or c++ program to find area of rectangle using switch case or C Program to Find the Areas of Different Geometrical Figures or area of a triangle with switch statements.

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

Logic:- Here Is Formula To Find Area of Circle, Rectangle And Triangle now you can easily get a solution. Just take n input and put the values in given formula and your answer is on the screen according to your input. If you are having problem in switch Case then First see this problem this will help you to understand better way of switch cases.


See This C Program For Remove All Vowels From A String Using Switch Case

Formula's

1. Area of Circle =====> 3.14*r*r (r=Radius)
2. Area of Rectangle ==> a*b
3. Area of Triangle ===> sqrt(s*(s-a)*(s-b)*(s-c));

Where S=(a+b+c)/2;


Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page, so we can help our community, and don't forget to Subscribe. Enter your Email and click to subscribe.

Solution:-

#include<iostream>
#include<math.h>

using namespace std;
int main()
{
/*Visit - www.programmingwithbasics.com*/
float a,b,c,s,r,area;

int ch;

cout<<"1.Area Of Circle";
cout<<"\n2.Area Of Rectangle";
cout<<"\n3.Area Of Triangle \n";
cout<<"\nEnter Your Choice :";

cin>>ch;

switch(ch)
{
case 1:
{
cout<<"\nEnter Radius Of The Circle: ";
cin>>r;
area=3.14*r*r;
break;
}
case 2:
{
cout<<"\nEnter Length And Breadth Of Rectangle:";
cin>>a>>b;
area=a*b;
break;
}
case 3:
{
cout<<"\nEnter Three Sides Of The Triangle:";
cin>>a>>b>>c;
s=(a+b+c)/2;
area=sqrt(s*(s-a)*(s-b)*(s-c));
break;
}
default: cout<<"\n Invalid Choice Try Again...!!!";
break;
}

cout<<"Area = "<<area<<endl;
return 0;
}

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date. If you have any Query or Question you can ask in the group, I will Try To Solve your Query and try to answers of your Questions withing 24 Hours, You can also Email me or comment below Please suggest to your Friends to join and like our page and don't forget to Subscribe. Enter your Email and click to subscribe.

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment