C# program to check the given number is positive or negative
Program.cs
int n;
Console.WriteLine("———————————————————————————————————————————");
Console.WriteLine("Program to check the given number is +ve/-ve");
Console.WriteLine("———————————————————————————————————————————");
Console.Write("Enter a number ");
n = Convert.ToInt32(Console.ReadLine());
if (n < 0)
{
    Console.WriteLine("\nEntered number is negative");
}
else if (n > 0)
{
    Console.WriteLine("\nEntered number is positive");
}
else
{
    Console.WriteLine("\nEntered number is zero");
}
Console.WriteLine("———————————————————————————————————————————");
Output
kodingwindow@kw:~/csharp$ dotnet run
———————————————————————————————————————————
Program to check the given number is +ve/-ve
———————————————————————————————————————————
Enter a number 0

Entered number is zero
———————————————————————————————————————————
kodingwindow@kw:~/csharp$ 
Advertisement