- Course
- Flow controls A
- Positive and negative
Positive and negative
Last updated:
8/22/2020
⁃
Difficulty:
Easy
Write a C# program that requests a number (x) and answers if it is positive or negative.
Input
- 5
Output
- Positive
Solution
- using System;
- public class PositiveAndNegative
- {
- public static void Main(string[] args)
- {
- int x = Convert.ToInt32(Console.ReadLine());
-
- if (x > 0)
- {
- Console.WriteLine("Positive");
- }
-
- if (x < 0)
- {
- Console.WriteLine("Negative");
- }
- }
- }