Program 4 : Program to find the Area and Perimeter of a Rectange.

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int l=20, b=30;
float a,p;
a=l*b;
p=2*(l+b);
printf("Area of rectangle=%.2f", a);
printf("\nPerimeter of rectangle=%.2f", p);
getch();
}


Output
Area of rectangle=600.00
Perimeter of rectangle=100.00

Explanation
"l" denotes to length and "b" denotes to breadth.
Applying the mathematical formula of Area i.e, a=l*b  and perimeter, p=2*(l+b) we got the answer and displayed by the specifier %.2f that will will show the result in two decimal value after the point.
Here a and p are declared as floating number because it may store floating number.

Comments

Popular posts from this blog

Unacceptable Individual Drives Twitter

ChatGPT on smartwatches

Program to find greatest number among any three different numbers inputted by User.