Your First C program !!
Hey there! Do you want to learn programming ? If so then do go through this post. This is one of the most basic program that we can have and you may even say that this is your first step towards learning any programming language. Here is the program:
#include<stdio.h>
int main()
{
printf("Hello World!");
return 0;
}
Wait a minute...! What is all of this ? Don't worry, there is explanation to each and every line. Let's go step by step:
- "#include" is known as a preprocessor directive. It is the first line of any C program. It tells the "compiler" to add/include everything which is there in "stdio.h" to our code. Now, you may wonder, why do need to include the "things" to our code? We will see that.
- The next line says "int main()". Now, any C program executes from the main function. That is why it is one of the most important statements in C. The "int" is telling that the "main()" must return some kind of integer value. It is the return type of the function mainNow, you may get an idea after looking at the code.
- "{}" or curly brackets. Everything inside this "{}" is the body of the function "main".
- The next line is printf("Hello World"). This "printf()" is coming from "stdio.h" library. The line does exactly what you are thinking. It prints the text "Hello World". This is actually a string (inside double inverted commas).
- In the end comes the "return 0" statement. This means that the value that is "returned" to the function is 0 (Note that the return type of main function is int).
Best of luck for your programming career!
THANKS FOR VISITING!
Leave Your First C program !! to:
Read more #technology posts
Best Posts From <the_cs_life/>
We have not curated any of bib15hash's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From <the_cs_life/>
- Drawing Naruto Uzumaki
- The kid in you.
- The kid in you.
- A game of sacrifices!!
- Guess the next move
- First Brilliancy in chess!!
- A poem about gaming 🙃. Do give it a read!
- What kind of sorcery is this..??
- Chicken Roll...yum!! The taste..damn!!
- Finally..!! reached LEVEL 20 on #RISING STAR
- Level 18++ RS
- Reached Level 18 and going..
- Your First C program !!
- So it is level 17 now !!
- My Entry to Dcity.io
- Level 10000 reached..!!
- So... Level 15 now !!
- Reached Level 14 just some moments ago in Rising Star.
- Another post for another achievement in Rising Star..
- Reached Level 11 of Rising Star.