Monday, June 18, 2012

To calculate area and circumference of a circle

/* To calculate area and circumference of a circle */
#include <stdio.h>

#include<conio.h>

/*Defining symbolic constants*/

#define PI 3.14159 

void main()

{

int r;

float area, circum;

clrscr();

printf("Enter the radius of the circle:\n");

scanf("%d ", &r);

/*To calculate area of the circle*/

area = PI * r * r;

/*To calculate circumference of the circle*/

circum = 2 * PI * r;

printf("\n Area of Circle = %f”, area);

printf("\n Circumference of Circle = %f ", circum);

getch();

}

 

OUTPUT

Enter the radius of the circle:

5

 Area of Circle = 78.539750

 Circumference of Circle = 31.41590

 
 
 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.