Why is the file saved as hashtable.h and not as hashtable.cpp

what does the extension .h mean and why aren’t we just making a cpp file . why a different file for main function and hash table

Hello @Anchal,

.h: a header file (to be included with a preprocessor #include directive). Contains stuff that is normally deemed to be shared with other parts of your code, like function prototypes, #define’d stuff, extern declaration for global variables (oh, the horror) and the like.

Technically, you could put everything in a single file. A whole C program. million of lines. But we humans tend to organize things. So you create different C files, each one containing particular functions. That’s all nice and clean. Then suddenly you realize that a declaration you have into a given C file should exist also in another C file. So you would duplicate them. The best is, therefore, to extract the declaration and put it into a common file, which is the .h

You can refer to the following link for a detailed explanation about header files:
Header Tutorial

Hope, this would help.
Give a like if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.