How to Check , the number is negative or positve in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace value
{
class Program
{
static void Main(string[] args)
{
double number;
Console.WriteLine("Enter the number.");
number = double.Parse(Console.ReadLine());
if (number >= 0)
{
Console.WriteLine("Enter the number is positve.");
}
else
{
if (number <= 0.0)
{
if (number == 0.0)
{
Console.WriteLine("Enter the number is positve.");
}
else
{
Console.WriteLine("Enter the number is negative.");
}
}
}
Console.ReadLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace value
{
class Program
{
static void Main(string[] args)
{
double number;
Console.WriteLine("Enter the number.");
number = double.Parse(Console.ReadLine());
if (number >= 0)
{
Console.WriteLine("Enter the number is positve.");
}
else
{
if (number <= 0.0)
{
if (number == 0.0)
{
Console.WriteLine("Enter the number is positve.");
}
else
{
Console.WriteLine("Enter the number is negative.");
}
}
}
Console.ReadLine();
}
}
}
output:-