program to check smallest num in three numbers in c++

#include <iostream>
using namespace std;

int main() {
    int num1, num2, num3;
    cout << "Enter three numbers: ";
    cin >> num1 >> num2 >> num3;

    if (num1 <= num2 && num1 <= num3) {
        cout << "Smallest number is " << num1;
    } else if (num2 <= num1 && num2 <= num3) {
        cout << "Smallest number is " << num2;
    } else {
        cout << "Smallest number is " << num3;
    }

    return 0;
}

Explanation:

  1. Include Input Output Stream Library: Include the necessary library for input and output operations.
  2. Using Namespace std: Use the standard namespace to avoid having to prefix standard functions and objects with "std::".
  3. Main Function: Define the main function to start the execution of the program.
  4. Declare Variables: Declare three integer variables num1, num2, and num3 to store the input numbers.
  5. Prompt User for Input: Output a message asking the user to enter three numbers.
  6. Read Input: Read the input values for num1, num2, and num3 from the user.
  7. Check Smallest Number: Use if-else statements to compare the three numbers and determine the smallest one.
  8. Output Smallest Number: Output the smallest number to the console.

This program takes three numbers as input from the user and then uses conditional statements to find and output the smallest number among the three.