Skip to content
Home » C program to find the area of a Rectangle

C program to find the area of a Rectangle

Learn about C program to find the area of a Rectangle in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

C program to find the area of a Rectangle

The area of a rectangle is calculated by multiplying its length by its width. We used the variables len and wid to store the length and width values, respectively. The below program prints the area of the rectangle using length and width.

Source code:

#include<stdio.h>
int main()
{

     // variables
     float len, wid, area;

     // inputs from user
     printf("Enter length & width of Rectangle (in cm): ");
     scanf("%f %f",&len,&wid);

     // calculating the area
     area = len * wid;

     // print result
     printf("Area of Rectangle= %.2f\n",area);

     return 0;
}

Output:

Enter length & width of Rectangle (in cm): 5 10
Area of Rectangle= 50.00

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
C program to find Area of a Circle Using Symbolic Constant
C Program to Find Area of a Circle Triangle and Rectangle