Tech Study

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

Introduction

Write C# Program to check number is positive, negative or zero. 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

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

Taggednegative or zeroWrite C# Program to check number is positive

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more