Simple Example Program for Function Find Smallest Number In C++

Definition

A function is like a black box. It takes in input, does something with it, then spits out an answer.

Syntax

return_type function_name(argumnent)
{
 // body Of the Function
}

Simple Example Program Of Function Find Smallest Number

/*  Example Program For Simple Example Program Of Function Find Smallest Number In C++
    little drops @ thiyagaraaj.com
    Coded By:THIYAGARAAJ MP             */

#include<iostream>
#include<conio.h>

using namespace std;

// Find Smallest Number compare Function
int compare(int a, int b) {
    return (a < b) ? a : b;
}

int main() {
    cout << "\nSmallest Number :" << compare(1, 10);
    cout << "\nSmallest Number :" << compare(31, 10);
    cout << "\nSmallest Number :" << compare(11, 8);
    getch();
    return 0;
}

Sample Output

Smallest Number :1
Smallest Number :10
Smallest Number :8