Course Content
Detailed Content of Programming in C
0/1
Introduction
0/1
Structure of C program
0/1
Answers of ‘C’ Pointers Programs
0/1
About Lesson

Develop a program that calculates the area of a circle. Prompt the user to enter the radius (a floating-point value), perform the calculation, and display the result with two decimal places.

#include <stdio.h>

int main() {
// Declare variables to store user input and result
float radius, area;

// Input: Get the radius from the user
printf(“Enter the radius of the circle: “);
scanf(“%f”, &radius);

// Process: Calculate the area of the circle (π * r^2)
area = 3.14159 * radius * radius;

// Output: Display the result with two decimal places
printf(“The area of the circle with radius %.2f is: %.2fn”, radius, area);

return 0; // Exit the program successfully
}