Calling Function of Custom Header File in C++

Calling Function of custom header file 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 Using Goto

Program

#include<iostream.h>
#include<conio.h>
void main()
{
cout<<"This is First Line"<<endl;
goto xyz; //going to 'xyz'
cout<<"This Code Never Execute";
xyz: //this is 'xyz', U also write without Braces'{}'.
{
cout<<"This is xyz Line"<<endl;
goto abc; //going to 'abc'.
}
cout<<"This Code also Never Execute";
abc: //this is 'abc', U also write without Braces'{}'.
{
cout<<"This is abc Line";
}
getch();
}
Output
This is First Line
This is xyz Line
This is abc Line

Program Adding .h File and Calling his Functions

Program

// Goto 'File' -> 'New' -> and Select 'Text Edit' and Write the following Code
// and Save File with '.h' Extension like 'MyFile.h'.
void fun() //this is Function.
 {
  cout<<"This is Simple Function"<<endl;
 }
 void fun2() //this is another Function.
 {
 cout<<"This is Another Simple Function";
 }

// Write the following Code in Main Program.
#include<iostream.h>
#include<conio.h>
#include "MyFile.h" //including 'MyFile.h' File.
void main()
{
fun(); //calling 'fun()' function.
fun2(); //calling 'fun2()' function.
getch();
}
Output
This is Simple Function
This is Another Simple Function

Program Adding .h Files and Calling his Functions

Program

// Write the following Code in 'MyFile.h' File.
 void fun() //this is function.
 {
  cout<<"This is Simple Function"<<endl;
 }
 void fun2() //this is function.
 {
 cout<<"This is Another Simple Function"<<endl;
 }

// Write the following Code in 'MyFile2.h' File.
void fun3() //this is function.
{
cout<<"This is Function of MyFile2.h File"<<endl;
}
void fun4(int arg) //passing here argument to parameter.
{
cout<<"This is Parameterized Function: "<<arg;
}

// Write the following Code in Main Program.
#include<iostream.h>
#include<conio.h>
#include "MyFile.h" //including 'MyFile.h' File.
#include "MyFile2.h" //including 'MyFile2.h' File.
void main()
{
fun(); //calling 'fun()' function.
fun2(); //calling 'fun2()' function.
fun3(); //calling 'fun3()' function.
fun4(54265); //calling and passing argument to parameter.
getch();
}
Output
This is Simple Function
This is Another Simple Function
This is Function of MyFile2.h File
This is Parameterized Function: 54265