pseudocode to find the minimum among three numbers
Answers
Example
Input: first = 15, second = 16, third = 10
Output: 10
Input: first = 5, second = 3, third = 6
Output: 3
Approach:
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:
// C++ implementation to find
// the smallest of three elements
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a = 5, b = 7, c = 10;
if (a <= b && a <= c)
cout << a << " is the smallest";
else if (b <= a && b <= c)
cout << b << " is the smallest";
else
cout << c << " is the smallest";
return 0;
}
Output:
5 is the smallest
Answer:
Pseudo-code
input Number1,Number2,Number3
if(Number1 < Number2) then
if(Number1 < Number3) then
display "Num1 is the smallest"
else
display "Num3 is the smallest"
end-if
else if(Number2 < Number3) then
display "Num2 is the smallest"
else
display "Num3 is the smallest"
end-if
Explanation: