Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- int main(){
- int n,m;
- float lengthSq,lengthRect,breadthRect,radius,base,height,pi=3.1416;
- float area;
- printf("Press 1 for proceeding and 2 for exiting the program....\n");
- scanf("%d",&n);
- if(n==1){
- printf("Ok, let's begin!!\n");
- printf("Press 1 for measuring the area of a Square.\n");
- printf("Press 2 for measuring the area of a Rectangle.\n");
- printf("Press 3 for measuring the area of a Circle.\n");
- printf("Press 4 for measuring the area of a Triangle.\n");
- scanf("%d",&m);
- if(m==1){
- printf("Enter the length of the square: ");
- scanf("%f",&lengthSq);
- area=pow(lengthSq,2);
- printf("Area: %f sq.unit\n",area);
- }
- else if(m==2){
- printf("Enter the length of the rectangle: ");
- scanf("%f",&lengthRect);
- printf("Enter the breadth of the rectangle: ");
- scanf("%f",&breadthRect);
- area=lengthRect*breadthRect;
- printf("Area: %f sq.unit\n",area);
- }
- else if(m==3){
- printf("Enter the raidus of the circle: ");
- scanf("%f",&radius);
- area=pi*radius*radius;
- printf("Area: %f sq.unit\n",area);
- }
- else if(m==4){
- printf("Enter the base of the triangle: ");
- scanf("%f",&base);
- printf("Enter the height of the triangle: ");
- scanf("%f",&height);
- area=(base*height)/2;
- printf("Area: %f sq.unit\n",area);
- }
- else{
- printf("Invalid Input!!");
- }
- }
- else if(n==2){
- printf("bye!!");
- }
- else{
- printf("Invalid Input!!");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement