R Program to check number is even or odd
In this program, You will learn how to check number is even or odd in R.
if(number %% 2) {
//statement
} else {
//statement
}
Example: How to check number is even or odd in R
{
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:
Enter a number :44
[1] "Number is even : 44"