In this tutorial you will learn about the C Program to Find Area of a Rhombus and its application with practical example.
C Program to Find Area of a Rhombus
In this tutorial, we will learn to create a C program that will Find the Area of a Rhombus in C programming.
Prerequisites
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.
Algorithm:-
1 2 3 4 5 6 7 8 9 |
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 Area of a Rhombus </strong>using the code. 4. Printing the area of the <strong>Rhombus</strong>. 5. End the program. |
Program description:-
In this tutorial, we will create a program, that will find the Area of the Rhombus. we will First, take the diagonals 1 and 2 of the Rhombus from the user. Then we will calculate the area of the Rhombus using arithmetic expressions / the formulae for the area of the rhombus. At last, we will print the Area of the Rhombus.
Program Code:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
/* * C Program to Find Area of rhombus */ #include <stdio.h>//including the header file int main()//main function body { //defining the required variabled for the program. float dia1, dia2; float area; //dia1 = it will hold the input value of diagonal 1 //dia2 = it will hold the input value of diagonal 2 //Taking the diagonals as input from the user. printf("Enter diagonals of the given rhombus: \n "); //Scanning the input diagonals from the user scanf("%f%f", &dia1, &dia2); //calculating the area of the rhombus area = 0.5 * dia1 * dia2; //printing the area of the rhombus printf("Area of rhombus is: %.3f \n", area); return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- dia1 = it will hold the input value for the diagonal1 of the Rhombus.
- dia2 = it will hold the input value for the diagonal2 of the Rhombus.
- area = it will hold the value of the area of the rhombus.
Taking the input diagonal1 and diagonal2 of the rhombus.
Calculating the area of the rhombus.
Printing the area of the rhombus.