C++ program to calculate parallelogram circumference

Views: 133   

Following program shows you how to calculate parallelogram circumference.
This program gets parallelogram base and side from user and calculates circumference and prints it using following formula
Circumference = 2 X base X side

#include <iostream>
#include <math.h>

int main() {
    float parallelogramBase;
    float parallelogramSide;

    std::cout << "Please enter base of parallelogram:";
    std::cin >> parallelogramBase;

    std::cout << "Please enter side of parallelogram:";
    std::cin >> parallelogramSide;

    float circumferenceOfParallelogram =
        2 * (parallelogramBase + parallelogramSide);

    std::cout << "Circumference of parallelogram is: "
              << circumferenceOfParallelogram;


Please enter base of parallelogram: 22
Please enter side of parallelogram: 33
Circumference of parallelogram is: 110
On By