# How to find out the area of the rhombus in C programming language?

25 views

I am learning C language and I want to find out the area of the rhombus in C programming language. I can find it using mathematics formula but I don't know, how can I find out the area of rhombus in C language?

+1 vote

That's really good to convert mathematics formulas in 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 C language. First of all, understand mathematics formula for area of 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

by (7.2k points) 5 22 47

The area of the rhombus is depended on the diagonals. We can specify these diagonals like - d1 and d2. The d1 represents the diagonal one and the d2 represents the diagonal two of the rhombus. We can find out the area or any diagonal using the C language.

Let's find out the area of the rhombus using C programming language.

To find out the area in C language, you need to declare three variables like - float a, float d1 and float d2.  You can define the value of the variables.

#include <stdio.h>

#include<math.h>

void main()

{

float a,d1,d2;

d1=6.0;

d2=6.0;

a=d1*d2/2;

printf("Area of the rhombus= %.f\n", a);

}

Output -

Area of the rhombus= 18

by (5.1k points) 4 18 48