In this video we discussed about how to write a program for find the area of rectangle in C Programming language. It is 2nd method for find the area of rectangle.
This program code is
#include stdio.h
int main()
{
float a,a1,l,l1,b,b1;
int ch;
printf("Choose unit for calculation\n");
printf("1. Length=cm\tBreath=cm\tArea=cm\n");
printf("2. Length=cm\tBreath=cm\tArea=m\n");
printf("3. Length=m\tBreath=m\tArea=m\n");
printf("4. Length=m\tBreath=m\tArea=cm\n");
printf("5. Length=m\tBreath=cm\t,Area=m\n");
printf("6. Length=m\tBreath=cm,\tArea=cm\n");
printf("7. Length=cm\tBreath=m\tArea=m\n");
printf("8. Length=cm\tBreath=m\tArea=cm\n");
scanf("\t%d",&ch);
printf("Enter the value of Length=");
scanf("%f",&l1);
printf("Enter the value of Breath=");
scanf("%f",&b1);
if(ch==1||ch==2)
{
l=l1;
b=b1;
}
else
{
if(ch==3||ch==4)
{
l=l1*100;
b=b1*100;
}
else
{
if(ch==5||ch==6)
{
l=l1*100;
b=b1;
}
else
{
if(ch==7||ch==8)
{
b=b1*100;
l=l1;
}
}
}
}
a1=l*b;
if(ch==2||ch==3||ch==5||ch==7)
{
a=a1/100;
}
else
{
printf("The area of Rectangle=%.2f",a1);
goto z;
}
printf("The area of Rectangle =%.2f",a);
z:
return(0);
}