Skip to content

Instantly share code, notes, and snippets.

@btechmag
Last active April 15, 2021 14:30
Show Gist options
  • Save btechmag/39c386f6a785dc5c697fd01d74667410 to your computer and use it in GitHub Desktop.
Save btechmag/39c386f6a785dc5c697fd01d74667410 to your computer and use it in GitHub Desktop.
C Program that reads three values from keyboard and checks whether it is possible to make a triangle with them and also calculate the perimeter.
#include<stdio.h>
int main()
{
float x,y,z,perimeter;
printf("enter the values of x, y, z:");
scanf("%f %f %f",&x, &y, &z);
if(x < (y + z) && y < (x + z) && z < (x + y))
{
perimeter = x + y + z;
printf("The perimeter of triangle = %f\n",perimeter);
}
else
{
printf("Not possible to create a triangle");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment