Pseudo code to find minimum among three numbers in python
Asked by admin @ in Computer Science viewed by 377 People
Pseudocode to find the minimum among three numbers
Asked by admin @ in Computer Science viewed by 377 People
Pseudocode to find the minimum among three numbers
Answered by admin @
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
Asked by admin @ in Computer Science viewed by 346 persons
Asked by admin @ in Math viewed by 356 persons
Asked by admin @ in Math viewed by 301 persons
Asked by admin @ in Math viewed by 331 persons
Asked by admin @ in Math viewed by 390 persons
Asked by admin @ in Computer Science viewed by 341 persons
Asked by admin @ in Math viewed by 388 persons
Asked by admin @ in Math viewed by 315 persons
Asked by admin @ in Math viewed by 346 persons
Asked by admin @ in Math viewed by 304 persons
Asked by admin @ in Math viewed by 304 persons
Asked by admin @ in Math viewed by 325 persons
Asked by admin @ in Math viewed by 307 persons
Asked by admin @ in Math viewed by 332 persons
Asked by maham237 @ in Mathematics viewed by 310 persons
Asked by admin @ in Computer Science viewed by 19030 persons
Asked by admin @ in Computer Science viewed by 15816 persons
Asked by admin @ in Computer Science viewed by 10977 persons
Asked by admin @ in Computer Science viewed by 10407 persons
Asked by admin @ in Computer Science viewed by 8145 persons
Asked by admin @ in Computer Science viewed by 7845 persons
Asked by admin @ in Computer Science viewed by 6492 persons
Asked by admin @ in Computer Science viewed by 5796 persons
Asked by admin @ in Computer Science viewed by 5696 persons
Asked by admin @ in Computer Science viewed by 5479 persons
Asked by admin @ in Computer Science viewed by 4986 persons
Asked by admin @ in Computer Science viewed by 4976 persons
Asked by admin @ in Computer Science viewed by 4690 persons
Asked by admin @ in Computer Science viewed by 4492 persons