Venciity

[Jumpstart C#] Conditional statements - integer numbers

Jan 22nd, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. // integer numbers { without operator star )
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace _3.integer_numbers___without_operator_star__
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             Console.Write("num1 = ");
  16.             int num1 = Int32.Parse (Console.ReadLine());
  17.             Console.Write("num2 = ");
  18.             int num2 = Int32.Parse(Console.ReadLine());
  19.             Console.Write("num3 = ");
  20.             int num3 = Int32.Parse(Console.ReadLine());
  21.  
  22.             int negatives = 0;
  23.             if (num1 < 0) negatives++;
  24.             if (num2 < 0) negatives++;
  25.             if (num3 < 0) negatives++;
  26.  
  27.             if (negatives % 2 == 0)
  28.                 Console.WriteLine("The product is a positive number");
  29.             else
  30.                 Console.WriteLine("The product is a negative number");
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment