To create a C program in linux environment, firstly we need to open the terminal by typing Ctrl+Alt+T or open terminal application using GUI. After that we can create a C program using the following editor command with a filename having extension .c:
As soon as we type the command a text-editor window opens up. We type our program in the window, save and then close the window.
Then to compile the program we type the following command:
gcc -o filename filename.c
If there is any error in the program, we need to edit the program again using the editor command otherwise we need to run the output file generated after compiling.We type the following command to run the program:
Note:For linking the math functions from the standard C library i.e. the program includes the math.h library then we use the following command to compile the program.
gcc -o filename filename.c -lm