Last active
October 4, 2023 03:58
-
-
Save ChaseFlorell/c99d1ea9bd84ade74c16e90b3c9657a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/****************************************************************************** | |
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