Search⌘ K
AI Features

Exercise 12: Creating Functions

Explore how to create a function in R that determines whether a given number is even or odd and prints the result with the cat function. This lesson helps you practice function creation, conditional logic, and output printing in R programming.

Problem Statement

Implement a function evenOdd that takes a number as input and prints “even” when the number is even and “odd” when the number is odd.

Use the cat() function for printing!

Input

A testVariable containing the number to be tested.

Output

Print “even” or “odd” depending on the testVariable.

Sample Input

78

Sample Output

"even"

Test Yourself

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

R
# Write your code here
cat(" ")