Problem statement:- Program to compute the area and perimeter of the Rhombus.
Formula:
Area Of Rhombus(A):
Formula:
Area Of Rhombus(A):
A
=
p×
q
2
where p and q =Diagonals length of the Rhombus
Perimeter of Rhombus(P):
P
=
4a
4a
Data requirement:-
Input Data:- a, p, q
Output Data:- area, perimeter
Output Data:- area, perimeter
Program in C
Here is the source code of the C Program to compute the area and perimeter of the Rhombus.
Code:
#include<stdio.h>
int main()
{
printf("Enter the two Diagonals Value:");
int p,q,a;
scanf("%d%d",&p,&q);
printf("Enter the length of the side value:");
scanf("%d",&a);
double area=(p*q)/2.0;
int perimeter=(4*a);
printf("Area of the Rhombus = %0.2lf\n",area);
printf("Perimeter of the Rhombus = %d",perimeter);
}
int main()
{
printf("Enter the two Diagonals Value:");
int p,q,a;
scanf("%d%d",&p,&q);
printf("Enter the length of the side value:");
scanf("%d",&a);
double area=(p*q)/2.0;
int perimeter=(4*a);
printf("Area of the Rhombus = %0.2lf\n",area);
printf("Perimeter of the Rhombus = %d",perimeter);
}
Input/Output:
Enter the two Diagonals Value:7
6
Enter the length of the side value:5
Area of the Rhombus = 21.00
Perimeter of the Rhombus = 20
Program in C++
Here is the source code of the C++ Program to compute the area and perimeter of the Rhombus.
6
Enter the length of the side value:5
Area of the Rhombus = 21.00
Perimeter of the Rhombus = 20
Program in C++
Here is the source code of the C++ Program to compute the area and perimeter of the Rhombus.
Code:
#include<iostream>
using namespace std;
int main()
{
cout<<"Enter the two Diagonals Value:";
int p,q,a;
cin>>p;
cin>>q;
cout<<"Enter the length of the side value:";
cin>>a;
double area=(p*q)/2.0;
int perimeter=(4*a);
cout<<"Area of the Rhombus = "<<area;
cout<<"\nPerimeter of the Rhombus = "<<perimeter;
}
Input/Output:using namespace std;
int main()
{
cout<<"Enter the two Diagonals Value:";
int p,q,a;
cin>>p;
cin>>q;
cout<<"Enter the length of the side value:";
cin>>a;
double area=(p*q)/2.0;
int perimeter=(4*a);
cout<<"Area of the Rhombus = "<<area;
cout<<"\nPerimeter of the Rhombus = "<<perimeter;
}
Enter the two Diagonals Value:7
9
Enter the length of the side value:10
Area of the Rhombus = 31.5
Perimeter of the Rhombus = 40
Program in Java
9
Enter the length of the side value:10
Area of the Rhombus = 31.5
Perimeter of the Rhombus = 40
Program in Java
Here is the source code of the Java Program to compute the area and perimeter of the Rhombus.
Code:
import java.util.Scanner;
public class Area_Perimeter_Rhombus {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
System.out.println("Enter the two Diagonals Value:");
int p,q,a;
p=cs.nextInt();
q=cs.nextInt();
System.out.println("Enter the length of the side value:");
a=cs.nextInt();
double area=(p*q)/2.0;
int perimeter=(4*a);
System.out.println("Area of the Rhombus = "+area);
System.out.println("Perimeter of the Rhombus = "+perimeter);
cs.close();
}
}
Input/Output:public class Area_Perimeter_Rhombus {
public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
System.out.println("Enter the two Diagonals Value:");
int p,q,a;
p=cs.nextInt();
q=cs.nextInt();
System.out.println("Enter the length of the side value:");
a=cs.nextInt();
double area=(p*q)/2.0;
int perimeter=(4*a);
System.out.println("Area of the Rhombus = "+area);
System.out.println("Perimeter of the Rhombus = "+perimeter);
cs.close();
}
}
Enter the two Diagonals Value:
5
8
Enter the length of the side value:
4
Area of the Rhombus = 20.0
Perimeter of the Rhombus = 16
5
8
Enter the length of the side value:
4
Area of the Rhombus = 20.0
Perimeter of the Rhombus = 16
Program in Python
Here is the source code of the Python Program to compute the area and perimeter of the Rhombus.
Code:
print("Enter the two Diagonals Value:")
p=int(input())
q=int(input())
a=int(input("Enter the length of the side value:"))
area=(p*q)/2.0
perimeter=(4*a)
print("Area of the Rhombus = ",area)
print("Perimeter of the Rhombus = ",perimeter)
Enter the two Diagonals Value:
10
12
Enter the length of the side value:20
Area of the Rhombus = 60.0
Perimeter of the Rhombus = 80
10
12
Enter the length of the side value:20
Area of the Rhombus = 60.0
Perimeter of the Rhombus = 80
Most Recommend Questions:-
More Questions:-
0 Comments
Please do not Enter any spam link in the comment box