OneCompiler

Determination of whether a number is even or odd (use of conditional statement)

Determination of whether a number is even or odd (use of conditional statement)

2 Answers

2 years ago by

| column 1 | column 2 |

~~

 
# 

~~

|---|---|
| row 1 value 1 | row 1 value 2 |
| row 2 value 2 | row 2 value 2 |


2 years ago by Ankit Kumar

Using JavaScript

function checkEvenOrOdd(number) {
  if (number % 2 === 0) {
      console.log(number + " is even");
  } else {
      console.log(number + " is odd");
  }
}

// Example usage:
checkEvenOrOdd(4);  // Output: 4 is even
checkEvenOrOdd(7);  // Output: 7 is odd
1 year ago by Sandeep Chauhan