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");
scanf("%d",&r);
a=pirr;
printf("\n Radius= %d",r);
printf(" \n Area= %f",a);
getch();
}
0 Comments