If my two input values are equal, the program returns true...otherwise it returns false.
How in the world will the user know it is true or false if neither will appear on the screen? My boolean function is facing that problem. Instead of using printf("True") or printf("False"); he wants something else.
My code is as follows.
There's something wrong with the logic in my AreSame bool function, isn't there?Code:/*Project #30d Herbert Ortiz Due: September 23, 2004 This program returns true if two values are equal, if not, it returns false*/ #include <stdio.h> #include <conio.h> typedef enum Bool {false=0, true=1} bool; //enables boolean functions int AreSame(int integer1, int integer2); //function prototype main() { int integer1, integer2, evaluation; //variables declared printf("Enter a number: "); //input prompt 1 scanf("%d", &integer1); //integer1 is stored in memory as a placeholder printf("Enter a number: "); //input prompt 2 scanf("%d", &integer2); //integer 2 is stored in memory as a placeholder evaluation=AreSame(integer1, integer2); //this calls the function getch(); } bool AreSame(int integer1, int integer2) //function header { int true=1, false=0; if(integer1==integer2) //all of the below make up the function definition { return true; //true is returned if the input values are the same } else //if they are not the same, false is returned { return false; } }



LinkBack URL
About LinkBacks



You are all passionate about this stuff, aren't you?