JulianJulianov

01.MethodsLab-Sign of Integer Numbers

Feb 11th, 2020
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. 1. Sign of Integer Numbers
  2. Create a method that prints the sign of an integer number n:
  3. Examples
  4. Input Output
  5. 2 The number 2 is positive.
  6. -5 The number -5 is negative.
  7. 0 The number 0 is zero.
  8.  
  9. using System;
  10.  
  11. namespace _01MethodsLabSignOfIntegerNumbers
  12. {
  13. class Program
  14. {
  15. static void Main(string[] args)
  16. {
  17. int number = int.Parse(Console.ReadLine());
  18. PrintSign(number);
  19. }
  20. static void PrintSign(int n)
  21. {
  22. if (n > 0)
  23. {
  24. Console.WriteLine($"The number {n} is positive.");
  25. }
  26. else if (n < 0)
  27. {
  28. Console.WriteLine($"The number {n} is negative.");
  29. }
  30. else
  31. {
  32. Console.WriteLine($"The number {n} is zero.");
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment