C LanguageProgramming

C Program to find Area Of a Circle

area of a circle
Spread the love

In this article, I will tell you a C program to find the area of a circle where the radius is entered by the user. It is a dynamic program which means you can take any value. Before you go to the program firstly you have to know some basics of C language which will help you to understand the program.

part 1
part 2

Above are two basic videos on C (in Hindi) watch both of them then go through the program part. Also, watch the video where I told about all operators of c language from here.

Program to find the area of a circle

	float area, radius, pi=3.14;  //decimal variables
	printf("enter radius");
	scanf("%f", &radius);  //radius input
	//area of circle = pi*r*r
	area = pi*radius*radius;  //area formula
	printf("The area is %f", area);	//printing the result

Here in the first two lines, I have used the header file and the main function. If you don’t know what they are and why I have used them then check out basic videos first.

float area, radius, pi=3.14; 

In the fourth line, I have used the float data type to declare two variables (decimal type) and one constant value of pi. In the radius variable, we will store the radius of a circle and in the area, we will store our final result.

printf("enter radius");

Here I have passed the message enter radius.

scanf("%f", &radius);

In line number six we will give input (radius) to our program and It will be stored in the address of radius variable.

Area of circle is π*r*r

area = pi*radius*radius;

In line number ten we will use a formula to find the area of a circle. We have radius stored in variable radius and π value is stored in variable pi. Now we just have to put the variables in the correct places and that’s what I have done in the above step.

printf("The area is %f", area);

In last we have to print our result store in the variable area. To do that we have to use printf statement and use %f to print float value (area variable).

Also read: C Program For Addition Of Two Integers (Entered By The User)

Program.docx: Download

Spread the love
Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.