C Programming Ex2
C Programming Ex2
AIM
To write C program to find the area of a circle and a rectangle with
preprocessing directive
ALGORITHM
Start
define PI value as 3.142 using Preprocessing directive
Read the radius of the circle (r)
Calculate area of the Circle using the formula area=PI*r*r;
Print the area of the Circle
Read length(l) and breadth(b) of the rectangle
Calculate area of the rectangle using the formula area=l *b
Print the area of the Rectangle
Stop
PROGRAM:
#include <stdio.h>
#include <conio.h>
#define PI 3.142
void main()
{
float r,l,b,area1,area2;
area1 = PI * r * r;
printf("\n Area of the Circle = %.2f ", area1);
area2=l*b;
printf("\n Area of the Rectangle = %.2f ", area2);
getch();
}
Result:
Thus, the C program to calculate area of a circle and a rectangle was executed
successfully.