Let us dive into C Part-2 (Hello World)

Spread to the Techies
Welcome beginners……

We are now ready to dive into C and it’s really very very easy now to code and test the code in your computer.

Our first program will be “Hello World” program. In this program we will know about the basic structure of a C program. How they will work on our compiler and what type of files will be created to run the code.

Open your IDE and create a new file from the menu or you can use shortcut keys, press (CRTL  SHIFT  N)  this will open a new file for you and save it as helloWorld.c   you are now in the file named hello world. This file has an extension named C. I wish you know about the file extensions. Here we will use some files with different file extensions like .c , .h and .exe.

.h stands for Header file
.c stands for C file
.exe stands for executable file.

Now we will write a code. copy the code below

#include<stdio.h>
main(){
      printf("Hello World");
}

Now press f9 key. By pressing this f9 key you will build this program and run on console.

What have you got?? yeah…. that’s it. It is the console where C code runs.

Now come to the explanation that how this program worked and why we had to write some extra lines to print hello world on the console.

what is #include<stdio.h>

#‘ is the pre-processor directive. When you will write # in the C program it will define some predefined tasks for running the program. Now when we write “#include this means it will include a file and we wrote stdio.h So, this #include command will include stdio.h named header file into this program.

What is stdio.h?

Std I O the breakdown of stdio and .h is the header file extension.

Std – Standard

I – Input

O – Output

main()‘  is the main block of this program. when we press f9 then the compiler search the main() keyword and then it starts compiling the whole program.

printf(“”); ” is the output function that is actually printing the hello world in the console.

Now check the directory where you saved the helloWorld.c file You will get a file named helloWorld.exe and this is the executable file of this program.

Task: Print your own name in the console using this code. Let me know if you face problem.

That’s all for today readers……. I wish you will comment here if any difficulties are there to understand my post and you will share if you find this Techie Post will help your friends or surroundings.

Thank you.

One thought on “Let us dive into C Part-2 (Hello World)”

Leave a Reply

Your email address will not be published. Required fields are marked *