C Program to Find Area of a Parallelogram

In this tutorial, we will learn how to find or calculate area of a parallelogram with the help of standard formula, function and pointer in c programs.

All C Programs and Algorithm to Find Area of a Parallelogram

  • Algorithm to Find Area of a Parallelogram
  • C Program to Find Area of a Parallelogram using Formula
  • C Program to Find Area of a Parallelogram using Function
  • C Program to Find Area of a Parallelogram using Pointer

Algorithm to Find Area of a Parallelogram

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

  1. Take input base and height of parallelogram. Store it in two different variables.
  2. Calculate area of parallelogram using perimeter=2*(length+breadth)
  3. Finally, print the value of area of parallelogram.

C Program to Find Area of a Parallelogram using Formula

#include<stdio.h>
int main()
{
	float base,height,area;
	printf("enter base of parallelogram: ");
	scanf("%f",&base);
	
	printf("enter height of the parallelogram: ");
	scanf("%f",&height);
	area=(base*height);
	printf("Area of parallelogram: %f\n",area);
	return 0;
}

The result of the above c program; as follows:

enter base of parallelogram: 10
enter height of the parallelogram: 30
Area of parallelogram: 300.000000

C Program to Find Area of a Parallelogram using Function

#include<stdio.h>
float area(float b,float h)
{
	return (b*h);
}
 
int main()
{
	float b,h,a;
	printf("enter base: ");
	scanf("%f",&b);
	
	printf("enter height: ");
	scanf("%f",&h);
	a=area(b,h);
	printf("Area of parallelogram: %f\n",a);
	return 0;
}

The result of the above c program; as follows:

enter base: 55
enter height: 63
Area of parallelogram: 3465.000000

C Program to Find Area of a Parallelogram using Pointer

#include<stdio.h>
void area(float *b,float *h,float *area)
{
	*area=((*b)*(*h));
}
 
int main()
{
	
 
	float b,h,a;
	printf("enter base: ");
	scanf("%f",&b);
	
	printf("enter height: ");
	scanf("%f",&h);
	area(&b,&h,&a);
	printf("Area of parallelogram: %f\n",a);
	return 0;
}

The result of the above c program; as follows:

enter base: 5
enter height: 63
Area of parallelogram: 315.000000

Be First to Comment

Leave a Reply

Your email address will not be published.