Q:

Write C# Program to check number is positive, negative or zero

0

Write C# Program to check number is positive, negative or zero. 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..

using System;
 
public class charpexercise
{
    static void Main(string[] args)
    {
        int num;
 
        Console.WriteLine("Enter any number: ");
        num = Convert.ToInt32(Console.ReadLine());        
 
        if (num > 0)
        {            
            Console.WriteLine("Enter number is positive ");
        }
        else if (num < 0)
        {
            Console.WriteLine("Enter number is nagative ");            
        }
        else
        {
            Console.WriteLine("Enter number is zero ");            
        }     
 
        Console.ReadLine();
    }
}

Result:

Enter any number: 

50

Enter number is positive 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now