Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Sign of Integer Numbers
- Create a method that prints the sign of an integer number n:
- Examples
- Input Output
- 2 The number 2 is positive.
- -5 The number -5 is negative.
- 0 The number 0 is zero.
- using System;
- namespace _01MethodsLabSignOfIntegerNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- int number = int.Parse(Console.ReadLine());
- PrintSign(number);
- }
- static void PrintSign(int n)
- {
- if (n > 0)
- {
- Console.WriteLine($"The number {n} is positive.");
- }
- else if (n < 0)
- {
- Console.WriteLine($"The number {n} is negative.");
- }
- else
- {
- Console.WriteLine($"The number {n} is zero.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment