We can easily Run and Compile C programs on Ubuntu Linux.
just follow below steps to run a compile C Program.

Step 1: Open a Terminal
Search for terminal application in dash tool or simply press ctrl+alt+t to open a terminal.

We have to use a text editor to write a C Program.

Step 2 : Open text Editor
To Open a text editor, just write the below code on the terminal.

gedit hello.c

hello is the file name, you can choose any file name and then put a ‘.c’ and hit enter.

 

Step 3: Write the Code
Now write the C program here, just like this.

#include<stdio.h>

void main()

{

printf(“\n Hello World \n”);

}

and SAVE the code and close the editor window and return to the terminal.

Step 4: Compile the Code
To Compile the saved code, just type the below command.

cc hello.c

or we can use –

gcc hello.c -o hello.out

here hello is the file name. If your code is right then it will end up with no errors.

Step 5: Run / Execute the Program
To run the code just type the following code on the terminal.

./a.out

or we can use –

./hello.out

and you will find the result.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!