How to include header files while compiling a program in ubuntu ? like string.h etc.
I know for compiling with include<math.h> we need to use gcc filename.c -o programname -lm
but what about others ?

You can easily run them using C++.
In ubuntu, first install the g++ compiler using terminal:

sudo apt-get install g++

now go to the folder containing your C++ file and compile it using:
g++ fileName.cpp

and you can run it by typing ./a.out

You can use it in the same way you included the math.h header file.

#include < string.h > 
#include < math.h >
#include < stdio.h >

gcc filename -lm.

this compiles any function of math.h and i think this solves your issue

for string.h and others simply include the header files it will not cause any trouble. only it is aused by math.h header file.

why go for C++ compiler? Doesn`t C have these header files? Sorry.I am new to programming.