R programming Write a function that takes any number and ret
(R programming) Write a function that takes any number and returns TRUE if its integer part is an even number and FALSE if it is odd.
By the integer part of a number I mean the nearest whole number smaller than that number if the number is positive—or larger than that number if it is negative. For example, the integer part of 21.6 is 21. The integer part of -1.9 is -1.
Solution
num = as.integer(readline(prompt=\"Enter a number: \")) if((num %% 2) == 0) { print(paste(num,\"is Even\")) } else { print(paste(num,\"is Odd\")) }