C# Program to Check Whether a Number is Positive or Negative

In this C# program, we will take input from the user and check whether a number is Positive or Negative. A Positive number is a number that is greater than 0 and a Negative number is a number that is lesser than 0. 

C# Program to Check Whether a Number is Positive or Negative Code:

private static void Main(string[] args)
        {
            Console.WriteLine("Enter the Number");
            decimal num = decimal.Parse(Console.ReadLine());
            if (num >= 0)
            {
                Console.Write("Entered number {0} is a positive number. ", num);
            }
            else
            {
                Console.Write("Entered number {0} is a negative number. ", num);
            }
            Console.ReadLine();
        }

C# Program to Check Whether a Number is Positive or Negative Output:

C#-Program-to-Check-Whether-a-Number-is-Positive-or-Negative

C#-Program-to-Check-Whether-a-Number-is-Positive-or-Negative

 
Best quality Asp .Net Ajax Control Toolkit tutorials.

Give your valuable comments.

Name
Email
Comment
5 + 4 =
 

About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2024 CodingFusion
50+ C# Programs for beginners to practice