Pages

Tuesday, December 24, 2013

Write a program that calculate circle’s area

Write a program that take radius of circle as input and then computes and displays circle’s area
Formula: Area = PI * r^2

Source Code:


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
       #include <stdio.h>
       #include <conio.h>
       void main (void)
# define PI 3.142857
{
 clrscr ();
float  A, r;
 printf("Enter the value of r: ");
 scanf(" %f", &r);
 A = (PI * (r * r));
 printf("\n Area of a circle = %f", A);
 getch();
 }

Result:


Enter the value of r: 3

Area of a circle = 28.285713

No comments:

Post a Comment