Dremendo Tag Line

Calculate area of a rectangle in C

scanf() - Question 12

In this question, we will see how to input length and breadth of a rectangle in C programming using the scanf() function and find its area. To know more about scanf() function click on the scanf() function lesson.

Q12) Write a program in C to input length and breadth of a rectangle and find its area.

Formula: area = length * breadth

Program

#include <stdio.h>
#include <conio.h>

int main()
{
    int l,b,a;
    printf("Enter length of a rectangle ");
    scanf("%d",&l);
    printf("Enter breadth of a rectangle ");
    scanf("%d",&b);
    a=l*b;
    printf("Area=%d",a);
    return 0;
}

Output

Enter length of a rectangle 10
Enter breadth of a rectangle 5
Area=50
video-poster