Welcome to Raspberry Pi 5 repository
2. Print Hello World
Print Hello World
Print Hello World1. Create new folders and files2. Write source code3. Compile source code4. Run the executable file
Use the GCC compiler to compile the source code and print the HelloWorld string in the terminal.
1. Create new folders and files
mkdir Democd Demo/nano HelloWorld.c
2. Write source code
Add the following code to the newly created HelloWorld.c file:
x// This is the first program#include <stdio.h>int main(void){printf("Hello World!\n");return 0;}
Hold down Ctrl+X, enter Y, then press Enter to save and exit!
3. Compile source code
Compile HelloWorld.c using GCC and name the resulting executable HelloWorld:
xxxxxxxxxxgcc HelloWorld.c -o HelloWorld
4. Run the executable file
xxxxxxxxxx./HelloWorld
The above are the steps to write, compile source code and generate executable files!
