ellapt

T9.2.GetMax

Jan 19th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. using System;
  2.  
  3. class GetMaxPrg
  4. {
  5. static int GetMax(int a, int b)
  6. {
  7. if (a > b) return a;
  8. else return b;
  9. }
  10.  
  11. static void Main()
  12. {
  13. int num1;
  14. int num2;
  15. int maxNum;
  16.  
  17. Console.Write("Enter an integer number: ");
  18. num1=int.Parse(Console.ReadLine());
  19. Console.Write("Enter second integer number: ");
  20. num2=int.Parse(Console.ReadLine());
  21.  
  22. maxNum = GetMax(num1, num2);
  23.  
  24. Console.Write("Enter third integer number: ");
  25. num1 = int.Parse(Console.ReadLine());
  26.  
  27. maxNum = GetMax(maxNum, num1);
  28.  
  29. Console.WriteLine("{0} is the maximal number.",maxNum);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment