Skip to content

Instantly share code, notes, and snippets.

@ChaseFlorell
Last active October 4, 2023 03:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChaseFlorell/c99d1ea9bd84ade74c16e90b3c9657a2 to your computer and use it in GitHub Desktop.
Save ChaseFlorell/c99d1ea9bd84ade74c16e90b3c9657a2 to your computer and use it in GitHub Desktop.
/******************************************************************************
Online C Compiler.
Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <stdio.h>
#include <stdbool.h>
int
main ()
{
printf ("Triangle Validator\n\n");
float angles[] = { 0, 0, 0 };
int i;
float sum;
for (i = 0; i < 3; i++)
{
while (angles[i] <= 0)
{
printf ("Please enter angle #%i: ", i + 1);
scanf ("%f", &angles[i]);
}
sum += angles[i];
}
bool valid = sum == 180;
printf("Your triangle angles are %s", valid ? "valid" : "invalid");
return !valid; // invert because exit codes are dumb
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment