Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstdlib>
- bool eq3(int a, int b, int c);
- int main(int argc, char* argv[])
- {
- char input[256];
- int a = 0, b = 0, c = 0;
- while(1)
- {
- printf("Type a number: ");
- for(short i = 0; i < 256; i++)
- input[0] = 0; // Zero out the char array - ensures a null terminated string.
- fscanf(stdin, "%s", input); // Read input from stdin
- if(input[0] < 48 || input[0] > 57) // Checks if input is an ascii number, returns false if not
- return 0;
- if(a == 0)
- a = atoi(input);
- else if(b == 0)
- b = atoi(input);
- else
- {
- c = atoi(input);
- bool chk = eq3(a, b, c);
- if(chk == true)
- printf("All values are equal.\n");
- else
- printf("Values are not equal.\n");
- a = 0;
- b = 0;
- c = 0;
- }
- }
- return 0; // This is here to keep the compiler from complaining...
- }
- bool eq3(int a, int b, int c)
- {
- int check = a;
- a |= (b | c);
- if(check != a)
- return false;
- else
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement