Basic program to calculate the area of a rectangle in c
#include <stdio.h>
int main()
{
int length = 20;
int breadth = 30;
int area = length * breadth;
printf("Area of the rectangle = %d", area);
}
Basic program to take inputs from users and calculate the area of a rectangle in c
#include<stdio.h>
#include<conio.h>
int main() {
int length, breadth, area;
printf("\nEnter the Length of a Rectangle in meter: ");
scanf("%d", &length);
printf("\nEnter the Breadth of a Rectangle in meter: ");
scanf("%d", &breadth);
area = length * breadth;
printf("\nArea of Rectangle : %d square meter", area);
return 0;
}
Output:
Enter the Length of a Rectangle in meter : 20
Enter the Breadth of a Rectangle in meter : 30
Area of Rectangle : 600 square meter
Basic program to calculate the area of a rectangle by creating function in c
#include <stdio.h>
int areaRectangle(int l, int b);
int main()
{
int l, b, area;
printf("\nEnter the length : ");
scanf("%d", &l);
printf("\nEnter the breadth : ");
scanf("%d", &b);
area = areaRectangle(l, b);
printf("\nArea of the Rectangle : %d", area);
return 0;
}
int areaRectangle(int l, int b)
{
return l * b;
}
Output:
Enter the Length : 20
Enter the Breadth : 30
Area of the Rectangle : 600