Program to calculate area of a Rectangle

Description

To calculate area of a Rectangle use formula
  area = length x breadth

C/C++

/* C Program to calculate area of a Rectangle */
//Save it as AreaRectangle.c

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

    float length, breadth, area;

    printf("Enter the length of Rectangle : ");
    scanf("%f",&length);

    printf("Enter the breadth of Rectangle : ");
    scanf("%f",&breadth);

    area = (length * breadth);

    printf("The area of Rectangle : %.3f", area);

    return 0;
}
Input:
Enter the length of Rectangle : 5
Enter the breadth of Rectangle : 3

Output:
The area of Rectangle : 15.0

Java

/* Java Program to calculate area of a Rectangle */
//Save it as AreaRectangle.java

import java.io.*;
import java.util.Scanner;

public class AreaRectangle {

    public static void main(String[] args) {

            Scanner scanner = new Scanner(System.in);
        
            float length, breadth, area;

        System.out.println("Enter the length of Rectangle : ");
        length = scanner.nextFloat();

        System.out.println("Enter the breadth of Rectangle : ");
        breadth = scanner.nextFloat();

        area = (length * breadth);

        System.out.println("The area of Rectangle : "+ area);
    }
}
Input:
Enter the length of Rectangle : 
5
Enter the breadth of Rectangle : 
3

Output:
The area of Rectangle : 15.0

Related Programs

1) Program to calculate area of a circle
2) Program to calculate area of triangle
3) Program to calculate Area Of right angle triangle
4) Program to calculate area of square
5) Program to calculate volume and surface area of cube
6) Program to calculate volume and surface area of cylinder
7) Program to calculate Volume and Surface Area of Sphere
Share Me

Leave a Reply