Given three numbers. The task is to find the smallest among given three numbers.
Input: first = 15, second = 16, third = 10 Output: 10 Input: first = 5, second = 3, third = 6 Output: 3
- Check if the first element is smaller than second and third. If yes then print it.
- Else if check if the second element is smaller than first and third. If yes then print it.
- Else third is the smallest element and print it.
Below is the implementation of the above approach:
5 is the smallest
Time complexity : O(1)
- Find the Kth smallest element in the sorted generated array
- Find smallest and largest element from square matrix diagonals
- Find the smallest after deleting given elements
- Find the k smallest numbers after deleting given elements
- Find the lexicographically smallest sequence which can be formed by re-arranging elements of second array
- Program to find smallest difference of angles of two parts of a given circle
- Replace every element with the smallest element on its left side
- Program to find largest element in an array
- Program to find the maximum element in a Matrix
- Program to find the minimum (or maximum) element of an array
- Average of remaining elements after removing K largest and K smallest elements from array
- Program to find sum of elements in a given array
- Python program to find sum of elements in list
- Python program to find N largest elements from a list
- Count of elements which are second smallest among three consecutive elements
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.