Solution: Even or Not
The main() function takes an integer input from the user, calls a separate function to check if it’s even, and prints whether the number is even or odd.
Defines a function
isEven(int number)that takes an integer and returnstrueif the number is divisible by 2 (number % 2 == 0), otherwise returnsfalse.In the
main()function, declares an integer variablenumto store user input.Prompts the user with "Enter an integer:" and reads the input into
num.Calls the
isEven()function withnumas the argument to check if it’s even.If the result is
true, prints "[number] is even.", otherwise prints "[number] is odd."Ends with
return 0;to indicate successful program completion.
Solution: Even or Not
The main() function takes an integer input from the user, calls a separate function to check if it’s even, and prints whether the number is even or odd.
Defines a function
isEven(int number)that takes an integer and returnstrueif the number is divisible by 2 (number % 2 == 0), otherwise returnsfalse.In the
main()function, declares an integer variablenumto store user input.Prompts the user with "Enter an integer:" and reads the input into
num.Calls the
isEven()function withnumas the argument to check if it’s even.If the result is
true, prints "[number] is even.", otherwise prints "[number] is odd."Ends with
return 0;to indicate successful program completion.