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 calculates the volume and surface area of a sphere using its radius. A sphere is a three-dimensional...
This C program converts a Roman numeral to a decimal number. Roman numerals are a system of numerical notation used...
This C program calculates the value of sin(x) using the Taylor series expansion. The Taylor series expansion is a mathematical...