TASK-
Write a C program for area and perimeter of rectangle and circle.
CODE:
#include<stdio.h>
#include<stdlib.h>
int main(){
int choice;
float l,b;
printf("Please select \n1-Area and perimeter of rectangle\n2-Area and circumference of circle \n\n");
scanf("%d",&choice);
switch(choice)
{
case 1: //for rectangle
printf("Enter length and breath of rectangle");
scanf("%f%f",&l,&b);
printf("\nArea = %0.2fcm2 and perimeter = %0.2f cm",l*b,(2*l+2*b));
break;
case 2: //for circle
printf("Enter radius: ");
scanf("%f",&l);
printf("\nArea = %0.2fcm2 and circumference = %0.2f cm",(3.14*l*l),(2*3.14*l));
break;
default:
printf("\nInvalid input");
exit(0);
}
getchar();
return 0;
}
EXPECTED OUTPUT:
1-
2-