HELLO WORLD

Let us write our first C program in C language. The problem is classic Hello world

CODE

#include< stdio.h>

int main()
{
printf("HELLO WORLD\n");

return 0;
}






HOW TO EXECUTE




Go on and write the code in the editor, compile and run the code.
For linux users, type ctrl+alt+t to open the terminal. Then type vi hello_world.c
This will open a new file called hello_world.c .
hello world is the name of the file and .c is the extension that tells the compiler that this file is a c program source code
press "i" to start typing, "i" stands for insert mode. type the following code in the file.
To save and exit, press "esc" Then type ":x" and then enter. Now you have saved and exit.
To compile the code , type gcc hello_world.c. This will compile the code
Now the final step, type ./a.out to run the program


Let us disect

#include< stdio.h> :
This means that we are telling the compiler to include a header file called stdio.h ( .h means header) which has functions like scanf and printf that helps us to take input and give output. We will include a separate article on #include

int main() {} :
Every C function must have a main function. This is the place from where the files start to execute. int means the return type of the function . int is a data type. We will add another article on data types in c :

return 0; :
This is the return value of the function. It means what the function returns on calling the function
For now just memorise that these will always be in your c program, no matter whatever program you are making

And finally printf("hello world\n");
It says to print the string "hello world" on screen
\n stands for a new line.

It will be easy to write code if you memorise the steps . With time, As you read further, you will understand these things in more detail.And it will give you a little bit of confidence if you are able to write code.