Write a C program for area and perimeter of rectangle and circle

 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-



NEED WORK PRODUCE WORK

My name is Abdul Rehman I am from Pakistan. I am doing BS in Computer and information sciences. Currently, I am creating these blogs to help students of computer sciences all over the world..

Post a Comment (0)
Previous Post Next Post