Exercise 9: ifelse()

Let's test your understanding of the "ifelse()" function.

Problem Statement

Given a vector of numbers, print a vector where each element tells whether the corresponding input vector’s element is an even number or an odd number.

Use cat() for printing.

Input

A testVariable containing the vector of numbers.

Output

A vector where each element corresponds to the correct condition of the elements of the input vector.

Sample Input

testVariable -> c(2, 10, 7, 400)

Sample Output

even even odd even

Test Yourself

Write your code in the given area. If you get stuck, you can look at the solution.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy