Venciity

[Jumpstart C#] Conditional statements - bigger number

Jan 22nd, 2014
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. // The bigger number of 3 numbers
  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 _4.The_bigger_number_of_3_numbers
  10. {
  11.     class Program
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             Console.Write("num1 = ");
  16.             int a = Int32.Parse(Console.ReadLine());
  17.             Console.Write("num2 = ");
  18.             int b = Int32.Parse(Console.ReadLine());
  19.             Console.Write("num3 = ");
  20.             int c = Int32.Parse(Console.ReadLine());
  21.  
  22.             int largest = 0;
  23.  
  24.             /*
  25.             if (a >= b && a >= c)
  26.                 largest = a;
  27.             else if (b >= a && b >= c)
  28.                 largest = b;
  29.             else
  30.                 largest = c;
  31.             */
  32.  
  33.             largest = a;
  34.             if (b > largest)
  35.                 largest = b;
  36.             if (c > largest)
  37.                 largest = c;
  38.  
  39.  
  40.             Console.WriteLine("The lagest number is {0}", largest);
  41.  
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment