In this tutorial you will learn about the C Program to Find Perimeter of a Rhombus and its application with practical example.
C Program to Find Perimeter of a Rhombus
In this tutorial, we will learn to create a C program that will Find the Perimeter of a Rhombus in C programming.
Before starting with this tutorial, we assume that you are the best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- Arithmetic operations in C programming.
What is a Rhombus?
The Rhombus is a quadrilateral shape having four sides its side are parallel with each other and of the same size. The size of the parallel sides is equal and the total of its interior angles is 360 degrees.
1. Declaring the required variables for the program.
2. Taking the input diagonals of the <strong>Rhombus </strong>from the user.
3. <strong>C</strong><strong>alculating the Perimeter of a Rhombus </strong>using the code.
4. Printing the Perimeter of the <strong>Rhombus</strong>.
5. End the program.
In this tutorial, we will create a program, that will find the Perimeter of the Rhombus. we will First, take the side of the Rhombus from the user. Then we will calculate the Perimeter of the Rhombus using arithmetic expressions / the formulae for the Perimeter of the rhombus. At last, we will print the Perimeter of the Rhombus.
//C Program to Find Perimeter of a Rhombus
#include <stdio.h>//including the header files for the program
int main()//body of the main function.
//declaring the required variablefor the program
float rmp, perimeter;
//rmp = it will hold float value of the input from the user.
//perimeter = it will hold the perimeter of the for the rhombus.
//Taking the input side from the user.
printf("Enter the Rhombus Side = ");
//Scanning the input from the user.
//Calculating the perimeter of the rhombus.
perimeter = 4 * rmp;
//Printing The Perimeter of the Rhombus.
printf("The Perimeter of the Rhombus = %.3f\n", perimeter);
In the above program, we have first initialized the required variable.
- rmp = it will hold the input value for the side of the Rhombus.
- perimeter = it will hold the perimeter of the Rhombus.
Taking the input side of the rhombus.
Calculating the Perimeter of the rhombus.
Printing the Perimeter of the rhombus.