Write a C program to input length and width of a rectangle and find area of the given rectangle. How to calculate area of a rectangle whose length and breadth are given by user in C programming.

Input length= 5

Input width = 10

Area of rectangle = 50 sq. units

Happy coding ;)

**Example:**Input length= 5

Input width = 10

Area of rectangle = 50 sq. units

### Required knowledge:

Fundamentals of C, Data types, Talking user input in C, Area of rectangle#### Area of rectanlge

Area of a rectangle can be given by: length * width### Program:

/** * C program to find area of rectangle */ #include <stdio.h> int main() { float length, width, area; /* * Read length and width of rectangle from user */ printf("Enter length of rectangle: "); scanf("%f", &length); printf("Enter width of rectangle: "); scanf("%d", &width); /* Calculates area of rectangle */ area = length * width; /* Prints the area of rectangle */ printf("\nArea of rectangle = %f sq. units ", area); return 0; }

Output

Enter length of rectangle: 5

Enter width of rectangle: 10

Area of rectangle = 50.000000 sq. units

Enter width of rectangle: 10

Area of rectangle = 50.000000 sq. units

Happy coding ;)

### You may also like

- Basic programming exercises in C.
- C program to enter two numbers and perform all arithmetic operations.
- C program to find perimeter of rectangle.
- C program to find diameter, circumference and area of circle.
- C program to convert length from meter to kilometer.
- C program to convert temperature from Celsius to Fahrenheit.
- C program to find area of triangle.
- C program to count total number of notes in a given amount.
- C program to find profit and loss on a product.
- C program to check whether a number is negative, positive or zero.

Thanks for nice post.know details

ReplyDelete