C Programming

Solved Example

Practice Questions

Exercise Question

Find area of rectangle is greater than perimeter

Objective:

Input the length and breadth of a rectangle, write a program to find whether the area of the rectangle is greater than its perimeter.

Area of Rectangle: length * breadth
Perimeter of Rectangle: 2 * (length + breadth)

Program / Solution:

#include<stdio.h>
int main() {
	int l,b,area,peri;
	
	printf("Enter the length and breadth of rectangle: ");
	scanf("%d %d",&l,&b);
	
	area = l * b;
	peri = 2 * (l + b);
	
	if(area > peri) {
		printf("The area is greater than perimeter");
	}else if(area < peri) { 
		printf("The area is lesser than perimeter");
	}else {
		printf("Both area and perimeter are equal");
	}
	return 0;
}

Sample Output:

Enter the length and breadth of rectangle: 12 30
The area is greater than perimeter

More Progarms of Decision Making in C

Calculate profit or loss

Check a number is even or odd

Check a number is positive or negative

Check a year is leap year or not

Find the first day of year

Find the youngest person

Absolute value of a number

Check the points are co-linear or not

Check a point is inside,outside or on the circle

Check the axis of a point

Identify a character is alphabet, digit and more

Check the insurance eligibility and calculate premium

Calculate the library penalty charges

Calculate grade of a student