GoogleTag

Google Search

[Programming] Question 30: Write a Program to find the area of a circle

 

#include <stdio.h>

#define PI 3.14159

int main() {
	float radius, area;

	printf("Enter the radius of the circle: ");
	scanf("%f", &radius);

	area = PI * radius * radius;

	printf("Area of the circle = %.2f\n", area);

	return 0;
} 
Inside the main() function:

- The program defines a constant `PI` with the value 3.14159.

- Float variables `radius` and `area` are declared to store the radius and the calculated area of the circle respectively.

- The user is prompted to enter the radius of the circle.

- The area of the circle is calculated using the formula `area = PI * radius * radius`.

- Finally, the program prints the area of the circle.

 

Featured Posts

SQL Interview Questions Topics

 SQL Topics to prepare for interviews,   SQL Basics: Introduction to SQL SQL Data Types DDL (Data Definition Language): C...

Popular Posts