FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 78   



Following program shows you how to take a number as input and tells its positive or negative.
In this program we get number from user, and if the number is less than zero it prints negative, and if the number is grater than zero it prints positive

using System;

class MainClass {
  public static void Main (string[] args) {
     Console.WriteLine("Please enter a number:");
    int input = Convert.ToInt32(Console.ReadLine());
    if (input < 0) {
      Console.WriteLine("Given number is -ve");
      } else {
        Console.WriteLine("Given number is +ve");
      }
  }
}

Output:

Example1:

Please enter a number:
 12
Given number is +ve

Example2:

Please enter a number:
 -5
Given number is -ve



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News