Compiling C Program using gcc compiler

The steps are given below:

1. Open terminal in Ubuntu(Ctrl+Alt+t).

2. Check for the gcc version available with the help of following command.

$ gcc –version or $ gcc -v

3. Open Text Editor now, where you can write your c program. To open this you can use either GUI or simply type gedit and enter in Terminal.

4. Now in Editor type the simple program, like

int main(void)
printf(“Name of this blog is\n”);
return 0;

* Lets save this file with the name first.c in Documents.

5. Now open terminal and check for a file. Type “ls” which will give you a list of all files available.

$ ls

*Complete list of all available directories and file is generated. As you have saved our file in Document so open Documents.

6. To open Documents type

$ cd Documents

Output- ubuntu@ubuntu-machine:~/Documents$
*Command cd is for change directory.

7. Dirctory is changed now. Check for your file first. Type

~/Documents$ ls

8. If there exists your file named first.c, now its time to compile this.

9. To Comile, type-

~/Documents$ gcc first.c

10. Now c program is Compiled.

11. To check Execute File, type-

~/Documents$ ls
a.out first.c first.c~

*a.out is execution format of the first.c

12. Now execute a.out by

~/Documents$ ./a.out


Name of this blog is


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s