C Programming

Solved Example

Practice Questions

Exercise Question

Calculate area of circle

Objective

Input the radius and calculate the area of a circle.

Formula: 3.14 * radius * radius

Program / Solution

#include<stdio.h>
int main() {
	float r,area;
	
	printf("Enter the radius of circle: ");
	scanf("%f",&r);
	
	area = 3.14f * r * r;
	
	printf("Area of circle: %.2f",area);
	
	return 0;
}

Output:

Enter width and height of rectangle: 20 100
Area of rectangle = 2000