Search code examples
c++if-statementreturnconditional-statements

Trying to use a conditional and return at the same time but it doesn't work


I'm trying to do this:

(number % 2 == 0) ? return 1 : return 0; 

But it doesn't work, does someone know why?


Solution

  • You should write this way:

    return (number % 2 == 0) ? 1 : 0;