Sorry for not replying, really long week at college. I've thought about the question and came up with a solution that somewhat works. It can determine if something is a polygon (I haven't tested this long enough to ensure it works with every combination), but now I'm stumped at determining if the polygon is a square.
Heres my updated code, please tell me what you think:
Code:
//Global Declarations
#include <stdio.h>
//Main function
int main(void)
{
//Variable Declarations
int side1;
int side2;
int side3;
int side4;
int sidechecker_1;
int sidechecker_2;
int sidechecker_3;
int sidechecker_4;
int total_1;
int total_2;
int total_3;
int total_4;
int sidecheckresult_1;
int sidecheckresult_2;
int sidecheckresult_3;
int sidecheckresult_4;
int verdict;
int squarecheck1;
int squarecheck2;
int squareresult;
//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 \n",side1,side2,side3,side4);
//Check if valid polygon
total_1 = side2 + side3 + side4;
sidechecker_1 = 1 - (side1 / total_1);
sidecheckresult_1 = sidechecker_1;
total_2 = side1 + side3 + side4;
sidechecker_2 = 1 - (side2 / total_2);
sidecheckresult_2 = sidechecker_2;
total_3 = side1 + side2 + side4;
sidechecker_3 = 1 - (side3 / total_3);
sidecheckresult_3 = sidechecker_3;
total_4 = side1 + side2 + side3;
sidechecker_4 = 1 - (side4 / total_4);
sidecheckresult_4 = sidechecker_4;
verdict = 1 - ((sidecheckresult_1 + sidecheckresult_2) % (sidecheckresult_3 + sidecheckresult_4));
//Check if square
squarecheck1 = (side1+side2)/(side3+side4);
squarecheck2 = side1+side2+side3+side4;
squareresult = 1 - (squarecheck1 % squarecheck2);
//Debug for top - added to make logical thinking easier for myself
printf("Sidechecker results- 1: %d 2: %d 3: %d 4: %d || Final verdict: %d || Square status: %d\n", sidecheckresult_1, sidecheckresult_2, sidecheckresult_3, sidecheckresult_4, verdict, squareresult);
// Print results
printf("Polygon status: %d\n", verdict);
printf("Square status: %d\n", squareresult);
return(0);
}
The square determining part is just something I did, it doesn't really work.
Edit: I don't have an option to change my coding color to C? I can't find it anywhere.