Last active
October 4, 2023 03:58
-
-
Save ChaseFlorell/c99d1ea9bd84ade74c16e90b3c9657a2 to your computer and use it in GitHub Desktop.
Revisions
-
ChaseFlorell revised this gist
Oct 4, 2023 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,6 +7,7 @@ Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> #include <stdbool.h> int main () @@ -22,8 +23,9 @@ main () 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 } -
ChaseFlorell revised this gist
Oct 4, 2023 . 1 changed file with 10 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,26 @@ /****************************************************************************** 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> 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 = sum + angles[i]; } -
ChaseFlorell created this gist
Oct 4, 2023 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #include <stdio.h> int main () { printf ("Triangle Validator\n\n"); int 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 ("%d", &angles[i]); } sum = sum + angles[i]; } printf("Your triangle angles are %s", sum == 180 ? "valid" : "invalid"); return sum != 180; }