C Programming : C Programming code to calculate area of a circle

C Programming code to calculate area of a circle by defining pi as 3.1415

Algorithm

Define pi as 3.1415 since pi is not a predefined constant in C

Accept the radius of the circle

Calculate the area of the circle

Display the output

Code

#include<stdio.h>
#include<conio.h>
#define pi 3.1415
void main()
{
clrscr();
int r;
float a;
printf("Enter the radius of a circle. \n"wink;
scanf("%d",&r);
a=pi*r*r;
printf("\n Radius= %d",r);
printf(" \n Area= %f",a);
getch();
}
Posted by makeale 01/05/2015 03:07 PM Comments
 

Archives