3). Simple Example Program for Function to Find Factorial In C++

Simple Function Example Programs  In C++


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


return_type function_name(argumnent)
// body Of the Function

Example Program

/*  Example Program For Simple Example Program Of Function Find Factorial Number In C++
    little drops @ thiyagaraaj.com

    Coded By:THIYAGARAAJ MP             */


using namespace std;

// Simple factorial Function
int factorial(int var)
    int fact=1;
    for(int i=1;i<=var;i++)
    fact = fact * i;
    return fact;

int main()                {
    cout<<"5 Factorial Number :"<<factorial(5);
    return 0;

Sample Output

5 Factorial Number :120