Write C# Program to check number is positive, negative or zero

Write C# Program to check number is positive, negative or zero


Introduction

Write C# Program to check number is positive, negative or zero. I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. using System;
  2.  
  3. public class charpexercise
  4. {
  5. static void Main(string[] args)
  6. {
  7. int num;
  8.  
  9. Console.WriteLine("Enter any number: ");
  10. num = Convert.ToInt32(Console.ReadLine());
  11.  
  12. if (num > 0)
  13. {
  14. Console.WriteLine("Enter number is positive ");
  15. }
  16. else if (num < 0)
  17. {
  18. Console.WriteLine("Enter number is nagative ");
  19. }
  20. else
  21. {
  22. Console.WriteLine("Enter number is zero ");
  23. }
  24.  
  25. Console.ReadLine();
  26. }
  27. }

Result

C# language techstudy.org

     





Related Topics




Popular Posts