Area and circumference of circle coderinme

area and circumference of circle in C

This program is used for simple calculation of circle.
If we want to find area of circle which is π.r.r
or circumference i.e 2.π.r
the we can use this code its easy

// 1 line comment in the program
/* multi line comment
ok
*/
area and circumference of circle in C

#include<stdio.h> 
// its a Pre-processor Directives used for Defining identifiers from Standard Libraries
#define PI 3.14
 /*we can define anything if we want to use it again & again like if we write "PI" anywhere it will be treated as 3.14 */
int main() {

//main function started
/* function is always like funtype functioname() { }
e.g. int main() { } */

float Circum, Area, rad;
// we use/define 3 variables and their type like Float , int , long, double

printf("\n Hi, please Enter the Radius=");
// simple output

scanf("%f",&rad);
// above code is used for read the value scanf() %f is float type &rad its a variable which is declared by user

Circum=2*PI*rad;

//formula of circum and area
Area=PI*rad*rad;

// output
printf("\n if the radius is=%.2f",rad);

// %.2f the output with 2 correct decimal place


printf("\n then Circumference of the circle will be=%.2f",Circum);
printf("\n and Area of the circle will be=%.2f",Area);

return 0;
}

output is
area and circumference of the circle
if you don’t know about circle then
click here

Hi, please Enter the Radius=14.7

if the radius is=14.70
then Circumference of the circle will be=92.32
and Area of the circle will be=678.52

Leave a reply:

Your email address will not be published.