Author : Rahul

Write a program to check whether a number is positive or negative


Program

using System;

namespace ProgrammingQuestion
{
 class Program
 {
   static void Main(string[] args)
   {
     //Variable Declaration
     string numberVal;
     int number;
     
     //User Input
     Console.Write("Enter Number:");
     numberVal = Console.ReadLine();
     number = Convert.ToInt32(numberVal);

     //Positive Number Logic and Print Result
     if (number < 0)
     {
       Console.WriteLine($"Number {number} is a Negative Number.");
     }
     else if (number > 0)
     {
       Console.WriteLine($"Number {number} is a Positive Number.");
     }
     else
     {
       Console.WriteLine($"Number {number} is equal to Zero.");
     }     
     Console.Read();
   }
 }
}

Output

Enter Number:6
Number 6 is a Positive Number.
Enter Number:-6
Number -6 is a Negative Number.