Write a C program to calculate the area and perimeter of a rectangle . or Write a program to calculate the area and perimeter of a rectangle in C
Code:
/*Write a C program to calculate the area and perimeter of a rectangle . or Write a program to calculate the area and perimeter of a rectangle Using C*/
#include<stdio.h>
int main()
{
double length,breadth;
double area,perimeter;
printf("Enter the length of rectangle:");
scanf("%lf",&length);
printf("Enter the breadth of rectangle:");
scanf("%lf",&breadth);
area=length*breadth;
perimeter=2*(length+breadth);
printf("Area of the rectangle = %0.2lf",area);
printf("\nPerimeter of the rectangle = %0.2lf",perimeter);
return 0;
}
Write a C++ program to calculate the area and perimeter of a rectangle . or Write a program to calculate the area and perimeter of a rectangle in C++
Code:
/*Write a C++ program to calculate the area and perimeter of a rectangle . or Write a program to calculate the area and perimeter of a rectangle using C++*/
int main()
{
double length,breadth;
double area,perimeter;
cout<<"Enter the length of rectangle:";
cin>>length;
cout<<"Enter the breadth of rectangle:";
cin>>breadth;
area=length*breadth;
perimeter=2*(length+breadth);
cout<<"Area = "<<area;
cout<<"\nPerimeter = "<<perimeter;
return 0;
}
Write a JAVA program to calculate the area and perimeter of a rectangle . or Write a program to calculate the area and perimeter of a rectangle in Java
Code:
/*Write a JAVA program to calculate the area and perimeter of a rectangle . or Write a program to calculate the area and perimeter of a rectangle using Java*/
import java.util.Scanner;
public class AreaPerimeterRectangle {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
double length,breadth;
double area, perimeter;
System.out.println("Enter the length of rectangle:");
length=cs.nextDouble();
System.out.println("Enter the breadth of rectangle:");
breadth=cs.nextDouble();
area=length*breadth;
perimeter=2*(length+breadth);
System.out.println("Area of the rectangle = "+area);
System.out.println("Perimeter of the rectangle = "+perimeter);
cs.close();
}
}
Code:
/*Write a C program to calculate the area and perimeter of a rectangle . or Write a program to calculate the area and perimeter of a rectangle Using C*/
#include<stdio.h>
int main()
{
double length,breadth;
double area,perimeter;
printf("Enter the length of rectangle:");
scanf("%lf",&length);
printf("Enter the breadth of rectangle:");
scanf("%lf",&breadth);
area=length*breadth;
perimeter=2*(length+breadth);
printf("Area of the rectangle = %0.2lf",area);
printf("\nPerimeter of the rectangle = %0.2lf",perimeter);
return 0;
}
Input/Output:
Enter the length of rectangle:5
Enter the breadth of rectangle:4
Area of the rectangle = 20.00
Perimeter of the rectangle = 18.00
Enter the breadth of rectangle:4
Area of the rectangle = 20.00
Perimeter of the rectangle = 18.00
Write a C++ program to calculate the area and perimeter of a rectangle . or Write a program to calculate the area and perimeter of a rectangle in C++
Code:
/*Write a C++ program to calculate the area and perimeter of a rectangle . or Write a program to calculate the area and perimeter of a rectangle using C++*/
int main()
{
double length,breadth;
double area,perimeter;
cout<<"Enter the length of rectangle:";
cin>>length;
cout<<"Enter the breadth of rectangle:";
cin>>breadth;
area=length*breadth;
perimeter=2*(length+breadth);
cout<<"Area = "<<area;
cout<<"\nPerimeter = "<<perimeter;
return 0;
}
Input/Output:
Enter the length of rectangle:7
Enter the breadth of rectangle:3
Area = 21
Perimeter = 20
Enter the breadth of rectangle:3
Area = 21
Perimeter = 20
Write a JAVA program to calculate the area and perimeter of a rectangle . or Write a program to calculate the area and perimeter of a rectangle in Java
/*Write a JAVA program to calculate the area and perimeter of a rectangle . or Write a program to calculate the area and perimeter of a rectangle using Java*/
import java.util.Scanner;
public class AreaPerimeterRectangle {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
double length,breadth;
double area, perimeter;
System.out.println("Enter the length of rectangle:");
length=cs.nextDouble();
System.out.println("Enter the breadth of rectangle:");
breadth=cs.nextDouble();
area=length*breadth;
perimeter=2*(length+breadth);
System.out.println("Area of the rectangle = "+area);
System.out.println("Perimeter of the rectangle = "+perimeter);
cs.close();
}
}
Input/Output:
Enter the length of rectangle:
7.5
Enter the breadth of rectangle:
8.0
Area of the rectangle = 60.0
Perimeter of the rectangle = 31.0
7.5
Enter the breadth of rectangle:
8.0
Area of the rectangle = 60.0
Perimeter of the rectangle = 31.0
Write a PYTHON program to calculate the area and perimeter of a rectangle . or Write a program to calculate the area and perimeter of a rectangle in Python
Code:
'''Write a Python program to calculate the area and perimeter of a rectangle .
or Write a program to calculate the area and perimeter of a rectangle using Python'''
length=int(input("Enter length of a rectangle :"))
breadth=int(input("Enter breadth of a rectangle :"))
area=length*breadth
perimeter=2*(length+breadth)
print("Area =",area)
print("Perimeter =",perimeter)
Code:
'''Write a Python program to calculate the area and perimeter of a rectangle .
or Write a program to calculate the area and perimeter of a rectangle using Python'''
length=int(input("Enter length of a rectangle :"))
breadth=int(input("Enter breadth of a rectangle :"))
area=length*breadth
perimeter=2*(length+breadth)
print("Area =",area)
print("Perimeter =",perimeter)
Input/Output:
Enter length of a rectangle :8
Enter breadth of a rectangle :5
Area = 40
Perimeter = 26
Enter breadth of a rectangle :5
Area = 40
Perimeter = 26