In this program, You will learn how to check number is even or odd in R.
R Program Example: How to check number is even or odd in R
1 2 3 4 5 6 7 8 9 10 11 12 | { num <- as.integer(readline(prompt = "Enter a number :")) if (num %% 2 == 0) { print(paste("Number is even :", num)) } else{ print(paste("Number is odd :", num)) } } |
Output:
1 2 3 4 | Enter a number :44 [1] "Number is even : 44" |