Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a function that accepts a numeric vector and returns only the even numbers.

Medium

Problem Statement

Create a function that accepts a numeric vector and returns only the even numbers.

Sample Input

Vector: c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

Sample Output

[1]  2  4  6  8 10

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined structure filter_even <- function(vector) { # Your logic here } result <- filter_even(c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) print(result)
Log in or sign up to run or submit your code.Log inSign up
Input
Vector: c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
Expected Output
[1]  2  4  6  8 10