Thus, the approach to find the area of rectangle in C are as follows:
Since we know that
Area of Rectangle = Length x Breadth
So, we need to input value of length and breadth and apply the above formula to calculate area of rectangle in C. So, Let's get started:
Logic to solve code:
1. First, Input the value of length and breadth using printf() and scanf() function.
2. Apply the above formula to calculate the result of area of rectangle.
3. Finally, Print the value of the result obtained by the area of rectangle.
Full Code to Find the Area of Rectangle in C Language:
/*
* Program to find out the area of rectangle in C Language
*/
#include<stdio.h>
int main()
{
int length, breadth, AreaOfRectangle;
/*
* length for storing the value of length of rectangle
* breadth for storing the value of breadth of rectangle
* AreaOfRectangle for storing the value of the result of area of rectangle
*/
printf("Enter the value of length\n");
scanf("%d",&length); // For taking the input of length
printf("Enter the value of breadth\n");
scanf("%d",&breadth); // For taking the input of breadth
AreaOfRectangle = length * breadth;
//Here AreaOfRectangle takes the result of multiplication of length and breadth
printf("Area Of Rectangle is %d",AreaOfRectangle);
//For printing the result of area of rectangle
return 0;
}
Please write this code on your own and Run this code and put the values of length and breadth different and see the output of the area of rectangle every time and comment your answer with input and output value.
As, everything is clear in the code, I hope you will be able to write a program how to find the area of rectangle in C language. If you have any query related to the above code or with this post. You are always welcome to post your query in the comment box!
0 Comments