Write a Program to find out the perimeter of Triangle, Rectangle and Circle using Switch case in C Programming

Hello,

The program is long as other program!

If you guys are not understanding the Code feel free to comment below!

First Please check the code.

#include<stdio.h>
void main(){
int option;
float r,l,b,a,c,res;
printf("Please Select any one option \n 1 For Perimeter of Circle \n 2 for Perimeter of Rectangle \n 3 for Perimeter of Triangle \n Your Choice: ");
scanf("%d",&option);
switch(option){
case 1:
    printf("Please Type the Value of Radius: ");
    scanf("%f",&r);
    res=2*22/7*r;
    printf("The Perimeter of circle is: %f",res);
    break;
    case 2:
    printf("Please Type the Value of L: ");
    scanf("%f",&l);
     printf("Please Type the Value of B: ");
    scanf("%f",&b);
    res=2*l+b;
    printf("The Perimeter of Rectangle is: %f",res);
    break;

case 3:
    printf("Please Type the Value of A: ");
    scanf("%f",&a);
     printf("Please Type the Value of B: ");
    scanf("%f",&b);
     printf("Please Type the Value of C: ");
    scanf("%f",&c);
    res=a+b+c;
    printf("The Perimeter of Triangle is: %f",res);
    break;
default:
    printf("Press Any Key to exit");
}
}

 

Understood ?

If not Comment down i will try my best to reply you as soon as i can!

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.