C Program to Find Area of Rhombus

In this tutorial, i am going to show you how to find or calculate area of rhombus with the help of standard formula, function and pointer in c programs.

All C Programs and Algorithm to Find Area of Rhombus

  • Algorithm to Find Area of Rhombus
  • C Program to Find Area of Rhombus using Standard Formula
  • C Program to Find Area of Rhombus using Function
  • C Program to Find Area of Rhombus using Pointer

Algorithm to Find Area of Rhombus

Just follow the below given algorithm to write a program to find the area of the rhombus; as follows:

  1. Take input two side of area of rhombus. Store it in two different variables.
  2. Calculate area of rhombus using area=(d1*d2)/2;
  3. Finally, print the value of Area of rhombus.

C Program to Find Area of Rhombus using Standard Formula

#include<stdio.h>
int main()
{
	float d1,d2,area;
	
	printf("enter diagonal1 of rhombus: ");
	scanf("%f",&d1);
	
	
	printf("enter diagonal1 of rhombus: ");
	scanf("%f",&d2);
 
	area=(d1*d2)/2;
	printf("Area of Rhombus: %f\n",area);
	return 0;
}

The result of the above c program; as follows:

enter diagonal1 of rhombus: 5
enter diagonal1 of rhombus: 6
Area of Rhombus: 15.000000

C Program to Find Area of Rhombus using Function

#include<stdio.h>
float area(float d1,float d2)
{
	return (d1*d2)/2;
}
 
int main()
{
	
	float d1,d2,a;
	
	printf("enter diagonal1 of rhombus: ");
	scanf("%f",&d1);
	
	
	printf("enter diagonal2 of rhombus: ");
	scanf("%f",&d2);
 
	a=area(d1,d2);
	printf("Area of Rhombus: %f\n",a);
	return 0;
}

The result of the above c program; as follows:

enter diagonal1 of rhombus: 10
enter diagonal2 of rhombus: 20
Area of Rhombus: 100.000000

C Program to Find Area of Rhombus using Pointer

#include<stdio.h>
void area(float *d1,float *d2,float *area)
{
	*area=((*d1)*(*d2))/2;
}
 
int main()
{
    
	float d1,d2,a;
	
	printf("enter diagonal1 of rhombus: ");
	scanf("%f",&d1);
	
	
	printf("enter diagonal2 of rhombus: ");
	scanf("%f",&d2);
 
	area(&d1,&d2,&a);
	printf("Area of Rhombus: %f\n",a);
	return 0;
}

The result of the above c program; as follows:

enter diagonal1 of rhombus: 6
enter diagonal2 of rhombus: 7
Area of Rhombus: 21.000000

More C Programming Tutorials

Leave a Comment