Write a program to find Area of a rectangle

22 November 2022

Write a program to find Area of a rectangle


Description

Get the value for length and breadth from the user and then calculate the area for the rectangle.

Area of rectangle = length * breadth

Input

2

4

Output

8.00


C Program

#include <stdio.h>

int main()

{

    float area,l,b;

    printf("Enter the length and breadth: ");

    scanf("%f %f",&l,&b);

    area=l*b;

    printf("%0.2f",area);

    return 0;

}


C++ Program

#include <iostream>

using namespace std;

int main()

{

    float area,l,b;

    cout<<"Enter the length and breadth: ";

    cin>>l>>b;

    area=l*b;

    printf("%0.2f",area);

    return 0;

}


Java

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter the length and breadth: ");

float length = sc.nextFloat();

float breadth = sc.nextFloat();

float area = length*breadth;

System.out.println(area);

}

}


Python

Python

length = int(input("Enter the length: "))

breadth= int(input("Enter the breadth: "))

area=length*breadth

print(area)


Related Articles

Ask Us Anything !