Technology has advanced to the point where programming has become an essential part of our lives. We use software and applications for communication, entertainment, education, and work, and these are all built on programming languages.

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.
Share:

No comments:

Post a Comment

If you have any doubt, let me know...

Translate

Wikipedia

Search results