Hello! Guys Welcome To My Blog!
Find the Number is Positive Or Negative In C#
Today we will be learn how to find number is positive of negative in this code we will be use only if else condition
Program to check this is Negative Or Positive Number
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace positive_negative_number
{
class Program
{
static void Main(string[] args)
{
while (true)
{//this while loop is used for take input from user,again and again
Console.WriteLine("Enter Any Number To Know That This Is Positive OR Negative");
int num = int.Parse(Console.ReadLine());
if (num > 0)//if number is greater than 0 its print Positive
{
Console.WriteLine("This Is Positive Number");
}
else if (num < 0)//if number is less than 0 its print Negative
{
Console.WriteLine("This is Negative Number");
}
else if (num == 0)//if number is Equal too 0 its print it is Not Positive Or Negative
{
Console.WriteLine("0 is Not Positive Or Negative");
}
}
}
}
}
OUTPUT!
Enter Any Number To Know That This Is Positive OR Negative
10
This is Positive Number
Enter Any Number To Know That This Is Positive OR Negative
-5
This is Negative Number
Enter Any Number To Know That This Is Positive OR Negative
0
0 is Not Positive Or Negative
Comments
Post a Comment