FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 69   



Following program shows you how to calculate triangle circumference.
This program gets triangle sides from user and calculates circumference and prints it using following formula
Circumference = side1 + side2 + side3

#include <stdio.h>

int main(void) {
    float triangleSide1;
    float triangleSide2;
    float triangleSide3;

    printf("Enter the side1 of triangle:");
    scanf("%f", &triangleSide1);

    printf("Enter the side2 of triangle:");
    scanf("%f", &triangleSide2);

    printf("Enter the side3 of triangle:");
    scanf("%f", &triangleSide3);

    float circumferenceOfTriangle =
        triangleSide1 + triangleSide2 + triangleSide3;

    printf("Circumference of triangle is: %f ", circumferenceOfTriangle);
}

Output:

Enter the side1 of triangle: 20
Enter the side2 of triangle: 20
Enter the side3 of triangle: 40
Circumference of triangle is: 80.000000



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News