Calling Function inside Function in C++

Calling Function inside Function in C++ programming. Functions are used to divide a large program into sub-programs for easy control. All these sub-programs are called sub-functions of the program.

Program Calling Functions Inside the Functions

Program

#include<iostream.h>
#include<conio.h>
void fun(); //defining Function 'fun()'.
void fun2(); //defining Function 'fun2()'.
void fun3(); //defining Function 'fun3()'.
void main()
{
cout<<"Before Calling Functions"<<endl;
fun(); //calling 'fun2()' function.
cout<<"After Calling Functions"<<endl;
getch();
}
void fun3() //this is 'fun3()' function.
{
cout<<"This is fun3() Function"<<endl;
fun2(); //calling 'fun()' function.
}
void fun() //this is 'fun()' function.
{
cout<<"This is fun() Function"<<endl;
fun3(); //calling 'fun3()' function.
}
void fun2() //this is 'fun2()' function.
{
cout<<"This is fun2() Function"<<endl;
 //if U call here 'fun();' function then Infinite.
}
Output
Before Calling Functions
This is fun() Function
This is fun3() Function
This is fun2() Function
After Calling Functions

Function Program Passing Argument

Program

#include<iostream.h>
#include<conio.h>
void fun(int); //defining function with Parameter.
void main()
{
int a = 8;
cout<<"Value of a: "<<a<<endl;
fun(a); //calling 'fun()' function and passing argument to parameter.
getch();
}
void fun(int x) //passing argument here to parameter'x'.
{
cout<<"Passed Value of x: "<<x;
}
Output
Value of a: 8
Passed Value of x: 8