C Program to Find Area Of Rectangle

C Program to Find Area Of Rectangle

C program to find area of a rectangle; Through this tutorial, we will learn how to find the area of rectangle using formula, function and pointers in c programs.

Programs and Algorithm to Find Area Of Rectangle

  • Algorithm to Find Area Of Rectangle
  • C Program to Find Area Of Rectangle using Formula
  • C Program to Find Area Of Rectangle using Function
  • C Program to Find Area Of Rectangle using Pointer

Algorithm to Find Area Of Rectangle

Use the following algorithm to write a program to find area of rectangle; as follows:

  1. Take input length and width of rectangle. Store it in two different variables.
  2. Calculate area of rectangle using area = length * width.
  3. Finally, print the value of area of rectangle.

C Program to Find Area Of Rectangle using Formula

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

The output of the above c program; as follows:

enter length of rectangle: 10
enter breadth of rectangle: 30
Area of Rectangle: 300.000000

C Program to Find Area Of Rectangle using Function

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

The output of the above c program; as follows:

enter length of rectangle: 50
enter breadth of rectangle: 25
Area of Rectangle: 1250.000000

C Program to Find Area Of Rectangle using Pointer

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

The output of the above c program; as follows:

enter length of rectangle: 55
enter breadth of rectangle: 15
Area of Rectangle: 825.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 *