Complete this program in just one line. It tells the user whether a number is even or odd.
Limitations:
=========
- No use of the Mod(%) operator
- no use of functions
- no use of classes
- no use of / * - +
- a line is counted by the amount of semicolons used. so your return statement counts as one line
- you cannot alter any other line in the code
Code :
======
#include <iostream>
using namespace std;
bool isEven(int f)
{
//one line here
}
int main (int argc, char * argv[])
{
int f = 10;
cout << f << ( isEven(f) ? " is even" : " is odd" ) << endl;
return 0;
}
Limitations:
=========
- No use of the Mod(%) operator
- no use of functions
- no use of classes
- no use of / * - +
- a line is counted by the amount of semicolons used. so your return statement counts as one line
- you cannot alter any other line in the code
Code :
======
#include <iostream>
using namespace std;
bool isEven(int f)
{
//one line here
}
int main (int argc, char * argv[])
{
int f = 10;
cout << f << ( isEven(f) ? " is even" : " is odd" ) << endl;
return 0;
}