2

(1.1K
Views)

I am learning the C language and I want to find out the area of the rhombus in the 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?

arnabisaha (2.4K Points)

in C Language 2 Answers

1

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

Comment

vishalrana1(7.3K Points)

answered 0

The area of the rhombus is depended on the diagonals. We can specify these diagonals like - d_{1} and d_{2}. The d_{1} represents the diagonal one and the d_{2 }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

Comment

Your Answer

You can post your answer after