How to compile c program in ubuntu or linux using gcc command method

First you need to open terminal then go to the folder through the terminal for example i have placed my source code to Downloads folder then i will type in terminal cd Downloads and press enter,after that use command like gcc -o sparse sparse.c

here we are using gcc compiler to compile the source code -o sparse we are saying to provide output with the name sparse and we have used sparse.c the name of file which is being compiled here.

now to run the program just drag the output file in terminal and press enter 

Remember the source code name(the file name containng source code you must add .c at the end of the file name so that the compiler can understand that it is a c program source code

Leave a Comment

Your email address will not be published. Required fields are marked *

Open chat