Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _1._SmallestOfThreeNumbers
- {
- class SmallestOfThreeNumbers
- {
- static void Main()
- {
- int firstNumber = int.Parse(Console.ReadLine());
- int secondNumber = int.Parse(Console.ReadLine());
- int thirdNumber = int.Parse(Console.ReadLine());
- int smallestNumber = GetSmallestNumber(firstNumber, secondNumber, thirdNumber);
- Console.WriteLine(smallestNumber);
- }
- static int GetSmallestNumber(int firstNumber, int secondNumber, int thirdNumber)
- {
- int smallest = 0;
- if (firstNumber <= secondNumber && firstNumber <= thirdNumber)
- {
- smallest = firstNumber;
- }
- else if (secondNumber <= firstNumber && secondNumber <= thirdNumber)
- {
- smallest = secondNumber;
- }
- else if (thirdNumber <= firstNumber && thirdNumber <= secondNumber)
- {
- smallest = thirdNumber;
- }
- return smallest;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement