How to write my own header file in C?

Steps to write my own header file in C −

  • Type a code and save it as “sub.h”.
  • Write a main program “subtraction.c” in which −
    • include new header file.
    • Write “sub.h” instead of <sub.h>
    • All the functions in sub.h header are now ready for use.
    • Directly call the function sub().
    • Both “subtraction.c” and “sub.h” should be in same folder.


int sub(int m,int n) {



#include "sub.h"
void main() {
   int a= 7, b= 6, res;
   res = sub(a, b);
   printf("Subtraction of two numbers is: %d", res);

After running ”subtraction.c” the output will be −


Subtraction of two numbers is: 1

Updated on: 30-Jul-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started