Program to calculate area of a Rectangle

Description

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
To calculate area of a Rectangle use formula
area = length x breadth
To calculate area of a Rectangle use formula area = length x breadth
To calculate area of a Rectangle use formula
  area = length x breadth

C/C++

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/* 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;
}
/* 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; }
/* 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;
}
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Input:
Enter the length of Rectangle : 5
Enter the breadth of Rectangle : 3
Output:
The area of Rectangle : 15.0
Input: Enter the length of Rectangle : 5 Enter the breadth of Rectangle : 3 Output: The area of Rectangle : 15.0
Input:
Enter the length of Rectangle : 5
Enter the breadth of Rectangle : 3

Output:
The area of Rectangle : 15.0

Java

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/* 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);
}
}
/* 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); } }
/* 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);
    }
}
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Input:
Enter the length of Rectangle :
5
Enter the breadth of Rectangle :
3
Output:
The area of Rectangle : 15.0
Input: Enter the length of Rectangle : 5 Enter the breadth of Rectangle : 3 Output: The area of Rectangle : 15.0
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