C ++程序在三个元素中找到最小的元素

在本教程中,我们将讨论一个程序,以在提供的三个元素中找到最小的元素。

我们将提供三个元素/整数,我们的任务是比较它们并找到其中最小的元素/整数。

示例

#include <bits/stdc++.h>
using namespace std;
int main() {
   int a = 45, b = 72, c = 10;
   if (a <= b && a <= c)
      cout << a << " is smallest" << endl;
   else if (b <= a && b <= c)
      cout << b << " is smallest" << endl;
   else
      cout << c << " is smallest" << endl;
      return 0;
}

输出结果

10 is smallest