Coding Exercise: Methods
Test yourself on the concept of methods in C#.
We'll cover the following
Problem
This exercise creates a method to determine if a number is positive or negative. Create a console-based application for a PositiveOrNegative
app that meets the requirements below:
- Write a method that receives an
integer
as an argument. - The method should determine if a number is positive or negative.
- Display a message with the number and whether it’s
positive
,negative
, orneither positive nor negative
(zero).
Sample input
The program accepts one int
parameter, for example:
121
-5
0
Expected output
The output of the program should look like the examples below:
The number 121 is positive
The number -5 is negative
The number 0 is neither positive nor negative
Get hands-on with 1400+ tech skills courses.