Monday 10 June 2013

Make your own Header Files in C/C++

Step 1 : Open C/C++ IDE or Notepad
Step 2 : Make Your own Function without "MAIN( )"
 Example : SUM.CPP / SUM.TXT

                 int sum(int,int);
                 int sum(int a, int b)
                {
                  return (a+b);
                }
Step 3 : Save the made function with extension ".H" and place the file in INCLUDE folder

Step 4 : Open any C/C++ program , INCLUDE your Header file and use your FUNCTION
           
#include<iostream.h>
 #include<sum.h>
 int main()
{ int a,b,c;
cin>>a>>b;
c=sum(a,b);
cout<<"\nSum of two numbers is "<<c;
return 0;
}


0 comments: