C Program to Find Area of Parallelogram

This C program calculates the area of a parallelogram using the base and height provided by the user.

Problem statement

Given the base and height of a parallelogram, we need to calculate its area using the formula area = base * height. The program should prompt the user to enter the base and height and then display the calculated area on the console.

C Program to Find Area of Parallelogram

#include <stdio.h>

int main() {
    float base, height, area;

    // Introduction
    printf("**** Area of Parallelogram Calculator ****\n");

    // Problem statement
    printf("Enter the base length and height of the parallelogram:\n");

    // User input
    scanf("%f %f", &base, &height);

    // Calculating the area
    area = base * height;

    // Output
    printf("The area of the parallelogram is: %.2f\n", area);

    return 0;
}

How it works

  1. The program starts with an introduction to indicate the purpose of the program.
  2. It then prompts the user to enter the base length and height of the parallelogram.
  3. The program reads the user input using scanf and stores the values in the variables base and height.
  4. The area of the parallelogram is calculated by multiplying the base length with the height and storing the result in the variable area.
  5. Finally, the program displays the calculated area using printf.

Input / output

C Program to Find Area of Parallelogram

Share:

Leave A Reply

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

You May Also Like

This C program finds the Greatest Common Divisor (GCD) of two given numbers. Problem Statement Write a C program that...
This C program calculates the roots of a quadratic equation of the form ax^2 + bx + c = 0....
This C program allows you to find the length of a linked list, which is the number of nodes present...