That's really good to convert mathematics formulas in the C programming language. I always said the C language is the base of every programming language. You can find out the area of the rhombus using the C language. First of all, understand the mathematics formula for the area of the rhombus.
Area of the rhombus - A = pq/2
A = Area of the rhombus.
p= Diagonal of the rhombus.
q= Diagonal of the rhombus.
You should understand the C concepts. There are three variables in the area of the rhombus A, p, q.
We can convert into C programming like - a=p*q/2
Where -
a = Area of the rhombus in C language.
p = Diagonal of the rhombus in C language.
q = Diagonal of the rhombus in C language.
Let's create a program to find out the area of the rhombus in the C programming language.
#include <stdio.h>
#include<math.h>
int main()
{
float a;
float p=2.0;
float q=4.5;
a=p*q/2;
printf("Area of the rhombus= %.2f\n", a);
return 0;
}
Compile and execute the above C program. You will get the area of the rhombus as output.
Area of the rhombus= 4.50