FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 109   



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);
}

Output:

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



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News