Dremendo Tag Line

Calculate area of a circle in C

scanf() - Question 13

In this question, we will see how to input the radius of a circle in C programming using the scanf() function and find its area. To know more about scanf() function click on the scanf() function lesson.

Q13) Write a program in C to input the radius of a circle and find its area. Area of a circle is πr2. Where r is the radius and the value of π (pie) is 22/7 or 3.142

Formula: area = 3.142 * r * r

Program

#include <stdio.h>
#include <conio.h>

int main()
{
    float r,a;
    printf("Enter radius of a circle ");
    scanf("%f",&r);
    a=3.142*r*r;
    printf("Area=%.2f",a);
    return 0;
}

Output

Enter radius of a circle 5
Area=78.55
video-poster