Connect with one of the following accounts


Please wait while we redirect...

Views: 78   

Following program shows you how to calculate square area and circumference.
This program gets square length from user and calculates area and circumference and prints them using following formulas
Area = length X length
Circumference = 4 X length

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

int main() {
    float squareLength;

    std::cout << "Enter length of square:";
    std::cin >> squareLength;

    float areaOfSquare = squareLength * squareLength;

    std::cout << "Area of square is: " << areaOfSquare << "\n";

    float circumferenceOfSquare = 4 * squareLength;

    std::cout << "Circumference of square is: " << circumferenceOfSquare;


Enter length of square: 18
Area of square is: 324
Circumference of square is: 72

On By

Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News