R Program to Check Age of a user is eligible for voting or not


In this program, You will learn how to check the age of a user is eligible for voting or not in R.


if( age >= 18) { 
    //statement
}

else{ 
    //statement
}

Example: How to Check Age of a user is eligible for voting or not in R

{
  age <- as.integer(readline(prompt = "Enter your age :"))

  if (age >= 18) {
    print(paste("You are valid for voting :", age))
  } else{
    print(paste("You are not valid for voting :", age))
  }

}

Output:

Enter your age :48
[1] "You are valid for voting : 48"