C Program to Find Area of Rhombus

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

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of 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 from a starting stage. As well as demo example.

Leave a Reply

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