Program to find Area of a rectangle

Program to find Area of a rectangle

17 May 2023

17 May 2023

Write a program to find Area of a rectangle


Description about the Program to find Area of a rectangle

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 to find Area of a rectangle

#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 to find Area of a rectangle

#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 Program to find Area of a rectangle

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 Program to find Area of a rectangle

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

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

area=length*breadth

print(area)



Related Articles

Ask Us Anything !