2.01 - Positive and negative

Objetive

Write a C# program to get a number from the and answer whether it is positive or negative.

Solution

using System;
public class PositiveAndNegative
{
    public static void Main() 
    {
        int a;
 
        Console.Write("Enter a number: ");
        a=Convert.ToInt32(Console.ReadLine());

        if(a>0)
            Console.WriteLine("is positive"); 
        if(a<0 data-blogger-escaped-console.writeline="" data-blogger-escaped-is="" data-blogger-escaped-negative="" data-blogger-escaped-pre="">

Popular Posts