Sign of a Number
Easyjava
Learn the Concept: Relational OperatorsRead an integer and print positive, negative or zero based on relational comparisons with 0.
Input: one integer.
Output: one line — positive, negative or zero.
Example 1
Input
7
Output
positive
Example 2
Input
-3
Output
negative
- -1000000000 <= n <= 1000000000
Hint 1
Test n > 0, then n < 0, otherwise it is zero.
Hint 2
Use if / else if / else.
Three outcomes, decided by comparing n against 0: greater than 0 is positive, less than 0 is negative, and the remaining case is zero.
Submit an attempt to unlock the solution. (Sign in first.)
Related Problems
- Compare Two Numbers Six WaysEasy · javaSolve Problem
- Larger of Two (No Math.max)Easy · javaSolve Problem
- Is It In Range?Easy · javaSolve Problem