Example: Sign of an Int NUmber

Create a method which prints the sign of an integer n.

Sample Input and Output

Input Output
2 The number 2 is positive.
-5 The number -5 is negative.
0 The number 0 is zero.

Hints and Guidelines

The first step is creating a method and giving it a descriptive name, e.g. PrintSign. This method will have only one parameter of type int.

The next step is implementing the logic by which the program will check what the sign of the number is. You can see from the examples that there are three cases - the number is larger than, equal to or lower than zero, which means that we'll make three verifications in our method.

The next step is to read the input number and to invoke the new method from the body of the Main method.

Testing in the Judge System

Test your solution here: https://judge.softuni.bg/Contests/Practice/Index/594#1.

results matching ""

    No results matching ""