0% found this document useful (0 votes)
1 views2 pages

C Programming Ex2

The document outlines a C program designed to calculate the area of a circle and a rectangle using a preprocessing directive for the value of PI. It includes an algorithm detailing the steps for reading inputs, performing calculations, and printing results. The program was executed successfully, confirming its functionality.

Uploaded by

Malathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views2 pages

C Programming Ex2

The document outlines a C program designed to calculate the area of a circle and a rectangle using a preprocessing directive for the value of PI. It includes an algorithm detailing the steps for reading inputs, performing calculations, and printing results. The program was executed successfully, confirming its functionality.

Uploaded by

Malathi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

EX.

NO: 2 AREA OF CIRCLE AND RECTANGLE


DATE:

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;

printf("Enter radius of the Circle: ");


scanf("%f", &r);

area1 = PI * r * r;
printf("\n Area of the Circle = %.2f ", area1);

printf("\n Enter length of rectangle (l): ");


scanf("%f", &l);
printf("\n Enter breath of the rectangle (b): ");
scanf("%f", &b);

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.

You might also like