Write a C program to enter radius of a circle and find its diameter, circumference and area.
/*
diameter = 2 r
circumference = 2 pi r
Area = pi r * r
*/
Static
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float pi = 3.14,dia,cir,area;
int r = 10;
dia = 2 * r;
cir = 2 * pi * r;
area = pi * r * r;
printf("\nThe area of circle :- %f",area);
printf("\nThe diameter of a circle :- %f",dia);
printf("\nThe circumference of a circle :- %f",cir);
getch();
}
Output :-
Dynamic
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float pi = 3.14,dia,cir,area;
int r;
printf("Enter the radius :- ");
scanf("%d",&r);
dia = 2 * r;
cir = 2 * pi * r;
area = pi * r * r;
printf("\nThe area of circle :- %f",area);
printf("\nThe diameter of a circle :- %f",dia);
printf("\nThe circumference of a circle :- %f",cir);
getch();