Advertisement
Kyosaur

[ANSWER] Another C++ Challenge

Mar 13th, 2011
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. //Oops this post was deleted due to me accidentally specifying 1 day as the expire time. Sorry!
  2.  
  3.  
  4.  
  5. /*
  6.  
  7. C++ challanege! Complete this program in just one line (it tells you if a number if odd).
  8.  
  9.  
  10. Limitations:
  11.  
  12.     * No use of the Mod(%) operator
  13.     * no use of functions
  14.     * no use of classes
  15.     * no use of / * - +
  16.     * a line is counted by the amount of semicolons used. so your return statement counts as one line
  17.     * you cannot alter any other line in the code
  18.  
  19. */
  20.  
  21. #include <iostream>
  22. using namespace std;
  23.  
  24. bool isEven(int f)
  25. {
  26.     //finish this function in one line.
  27.     return !(f & 1);
  28. }
  29.  
  30. int main (int argc, char * argv[])
  31. {
  32.     int f = 10;
  33.  
  34.     cout << f << ( isEven(f)  ?  " is even" : " is odd" ) << endl;
  35.  
  36.     system("pause");
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement