C Language program to calculate square area and circumference

Views: 50   

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 <stdio.h>

int main(void) {
    float squareLength;

    printf("Enter length of square:");
    scanf("%f", &squareLength);

    float areaOfSquare = squareLength * squareLength;

    printf("Area of square is: %f \n", areaOfSquare);

    float circumferenceOfSquare = 4 * squareLength;

    printf("Circumference of square is: %f ", circumferenceOfSquare);


Enter length of square: 15
Area of square is: 225.000000 
Circumference of square is: 60.000000
On By