This is a C Program to find area of rhombus.
This C Program calculates the area of Rhombus.
The formula used in this program are Area= (1/2) * height * width.
Here is source code of the C Program to Find the area of rhombus.The C program is successfully compiled and run on a Linux system. The program output is also shown below.
/* * C Program to Find Area of rhombus */ #include <stdio.h> int main() { float diagonal1, diagonal2; float area; printf("Enter diagonals of the given rhombus: \n "); scanf("%f%f", &diagonal1, &diagonal2); area = 0.5 * diagonal1 * diagonal2; printf("Area of rhombus is: %.3f \n", area); return 0; }
In this C program, library function defined in <math.h> header file is used to compute mathematical functions. We are reading the diagonal value of the rhombus using ‘diagonal1’ and ‘diagonal2’ variables. To find the area of a rhombus, the following formula is used.
Area = 0.5* diagonal1 * diagonal2
Output: $ cc pgm26.c $ a.out Enter diagonals of the given rhombus: 30 40 Area of rhombus is: 600.000
Sanfoundry Global Education & Learning Series – 1000 C Programs.
Here’s the list of Best Books in C Programming, Data-Structures and Algorithms
- Practice Computer Science MCQs
- Watch Advanced C Programming Videos
- Check Computer Science Books
- Apply for Computer Science Internship
- Check C Books