C Program to Find Area of Rhombus

C program to find area of rhombus; Through this tutorial, we will learn how to find or calculate area of rhombus using standard formula, function and pointer in c programs.

Programs and Algorithm to Find Area of Rhombus

Let’s checkout the following algorithm and programs to find or calculate area of rhombus using standard formula, function and pointer in c:

  • 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

Use the following 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 output 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 output 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 output of the above c program; as follows:

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

Recommended C Programs

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *