2). Simple Example Program for Function Find Smallest Number In C++

Find Small Number Program In C++,Simple Function Example Programs  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
}

Example Program:

/*  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;

// Simple Function
int compare( int a, int b )
{
    return (a+4 < 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