ellapt

4.5.GreaterOfTwoNum

Dec 7th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. using System;
  2. class GreaterOfTwoNum
  3. {
  4. static void Main()
  5. {
  6. Console.WriteLine("Get two numbers from the console\nand print the greater of them, without if statements");
  7. string inputNum;
  8. int num1;
  9. int num2;
  10. do
  11. {
  12. Console.Write("Enter an integer number: ");
  13. }
  14. while (!int.TryParse(inputNum = Console.ReadLine(), out num1));
  15. do
  16. {
  17. Console.Write("Enter second integer number: ");
  18. }
  19. while (!int.TryParse(inputNum = Console.ReadLine(), out num2));
  20. Console.WriteLine("{0} is greater than {1}", Math.Max(num1,num2), Math.Min(num1,num2));
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment