![]() |
VOOZH | about |
To compile and run a C program in Ubuntu, you need the GCC compiler, which is included in the build-essential package. After installing it, you can create, compile, and execute C programs directly from the terminal.
sudo apt update
sudo apt install build-essential
Verify that GCC is installed:
gcc --version
Use the touch command to create a new C source file:
touch hello.c
Open the file using a text editor such as Nano:
nano hello.c
Write a basic C program:
Hello world
Compile the program using GCC:
gcc hello.c
This command generates an executable file named a.out by default.
To specify an output file name:
gcc hello.c -o hello
./hello
Now, we can see the actual output of Hello World in our terminal of the hello.c system file.
Also Read