Friday, 1 December 2017

C# Program to Accept a Number from the user and Display it if it is Positive


Code:

using System;
class program
{
    public static void Main(string[] args)
    {
        Console.WriteLine("Enter a number: ");
        int number = Convert.ToInt32(Console.ReadLine());
        if (number > 0)
        {
            Console.WriteLine("Number is positive");
        }
        else if (number == 0)
        {
            Console.WriteLine("Number is 0");
        }
        else
        {
            Console.WriteLine("Number is negative");
        }
        Console.ReadLine();
    }
}

Output:

Enter a Number : -4 
Number is Negative


More C# Programs:




















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...