Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the length of four sides determine whether they can be used to create a po

ID: 440271 • Letter: G

Question

Given the length of four sides determine whether they can be used to create a polygon and determine if that polygon is a square. A polygon can be created if no single side is greater than the sum of the other three sides. Display a ONE when the status (polygon or square) is confirmed and ZERO when the status cannot be confirmed. DO NOT use any material found outside of the first THREE chapters of the C text. ? The use of any selection constructs (if/else, switch, conditional expressions), logical and relational operators (&&, ||, !, <, <=, ==, >=, >), and Boolean variables are prohibited on this assignment. Any such use will result in a zero.

Explanation / Answer

//Global Declarations #include //Main function int main(void) { //Variable Declarations int side1; int side2; int side3; int side4; //Ask the user for the four sides printf("Enter the length of the four sides:"); scanf("%d", &side1); scanf("%d", &side2); scanf("%d", &side3); scanf("%d", &side4); //Print the user input on screen printf("Length of sides: %d %d %d %d ",side1,side2,side3,side4); //Check if valid polygon truth = isPolygon(s1,s2,s3,s4); // the obvious if ( truth ) { printf("ONE "); } else { printf("ZERO "); } // the obfuscated (but still uses "selection" as you put it) printf("%s ", truth ? "ONE" : "ZERO" ); // the devious - only if truth is specifically 0 or 1 const char *messages[] = { "ZERO", "ONE" }; printf("%s ", messages[truth] ); return(0); }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote