Advertisement
MZlatev

Untitled

Oct 18th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _1._SmallestOfThreeNumbers
  4. {
  5. class SmallestOfThreeNumbers
  6. {
  7. static void Main()
  8. {
  9. int firstNumber = int.Parse(Console.ReadLine());
  10. int secondNumber = int.Parse(Console.ReadLine());
  11. int thirdNumber = int.Parse(Console.ReadLine());
  12.  
  13. int smallestNumber = GetSmallestNumber(firstNumber, secondNumber, thirdNumber);
  14. Console.WriteLine(smallestNumber);
  15.  
  16. }
  17.  
  18. static int GetSmallestNumber(int firstNumber, int secondNumber, int thirdNumber)
  19. {
  20. int smallest = 0;
  21.  
  22. if (firstNumber <= secondNumber && firstNumber <= thirdNumber)
  23. {
  24. smallest = firstNumber;
  25. }
  26.  
  27. else if (secondNumber <= firstNumber && secondNumber <= thirdNumber)
  28. {
  29. smallest = secondNumber;
  30. }
  31.  
  32. else if (thirdNumber <= firstNumber && thirdNumber <= secondNumber)
  33. {
  34. smallest = thirdNumber;
  35. }
  36.  
  37. return smallest;
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement