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

Programming Exercises

Write an R program to calculate the sum of all elements in a vector.

Easy

Problem Statement

Write an R program to calculate the sum of all elements in a vector.

Sample Input

Vector: [5, 10, 15, 20, 25]

Sample Output

Sum: 75

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined structure vector <- c(5, 10, 15, 20, 25) sum_value <- sum(vector) print(paste("Sum:", sum_value))
Log in or sign up to run or submit your code.Log inSign up
Input
Vector: [5, 10, 15, 20, 25]
Expected Output
Sum: 75