In this post, we will learn how to find the area of a parallelogram using C Programming language.
A parallelogram is defined as a quadrilateral in which both pairs of opposite sides are parallel and equal.
The area of a parallelogram is the space enclosed between the four sides of a parallelogram.
- Area of Parallelogram = Base x Height
We will be using the above formula in our program to compute the area of parallelogram.
So, without further ado, let’s begin this tutorial.
C Program to Find Area of Parallelogram
// C Program to Find Area of Parallelogram #include <stdio.h> int main(){ int height, base; long area; // Asking for input printf("Enter the height of parallelogram: "); scanf("%d", &height); printf("Enter the base of parallelogram: "); scanf("%d", &base); // Calculating area area = height * base; // Displaying area printf("Area of Parallelogram: %ld", area); return 0; }
Output
Enter the height of parallelogram: 4
Enter the base of parallelogram: 7
Area of Parallelogram: 28
How Does This Program Work ?
int height, base; long area;
In this program, we have declared two int data type variables and one long data type variable.
// Asking for input printf("Enter the height of parallelogram: "); scanf("%d", &height); printf("Enter the base of parallelogram: "); scanf("%d", &base);
Then, the user is asked to enter the height and base of the parallelogram.
// Calculating area area = height * base;
We calculate the area of parallelogram using the formula:
Area = Base x Height
// Displaying area printf("Area of Parallelogram: %ld", area);
Finally, the result is displayed to the screen using printf() function.
Conclusion
I hope after going through this post, you understand how to find the area of parallelogram using C Programming language.
If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to help you.
Also Read: