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

Programming Exercises

Write an R program to use an if statement to check if a number is positive, negative, or zero.

Easy

Problem Statement

Write an R program to use an if statement to check if a number is positive, negative, or zero.

Sample Input

Number: -5

Sample Output

The number is negative

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined structure num <- -5 if (num > 0) { print("The number is positive") } else if (num < 0) { print("The number is negative") } else { print("The number is zero") }
Log in or sign up to run or submit your code.Log inSign up
Input
Number: -5
Expected Output
The number is negative