Write a C Program to calculates the area (floating point number with two decimal places) of a Circle given it’s radius (integer value).

Write a C Program to calculates the area (floating point number with two decimal places) of a Circle given it’s radius (integer value).  The value of Pi is 3.14.


At first, we have to include the header file i.e.
#include<stdio.h>
Next, Define the value of PI  3.14
 #define PI 3.14
#Define used to define the value or definition of a name. Here PI define as 3.14. Now the value of PI that you can use in any function of the same program, without initializing multiple times for multiple functions.

Next, initialize the main function and inside main function initialize area as a floating-point and radius as integer. now take the input in radius with use of scanf () function then write the formulae i.e. area=PI*radius*radius and then print the value of area .

Write a C Program to calculates the area of a Circle if it's radius is given full code


#include <stdio.h>
 #define PI 3.14
void main()
{
float area;
int radius;
printf(" Enter the radius of a circle /n");
scanf("%d", &radius);
area=PI*radius*radius;
int radius;


printf("Area of a circle = %5.2f\n", area);
}





Post a Comment

0 Comments