Please help me debug my code in R for finding odd and even [closed]

Solution for Please help me debug my code in R for finding odd and even [closed]
is Given Below:

x <- (readline(prompt = "Enter number :" ))
 as.numeric(x) 
 if(x%% 2 ==0) {
 print("x is even")
 } else {
 print("x is odd") 
 }

Error in x%%2 : non-numeric argument to binary operator

You didn’t assign the return value of as.numeric to x for the following if...else... statement.

You can try the code below, which should work as you expected:

x <- as.numeric(readline(prompt = "Enter number :"))
if (x %% 2 == 0) {
  print("x is even")
} else {
  print("x is odd")
}