Hello world Program with detailed explanation
Fig 1.1
- In above Program We can see that we have Created a file with name main.c.Here we have given .c Extension Because when we want to run C program we must have .c or .cpp extension otherwise compiler will not perform further operation.
- In 2nd line of our code We have included stdio.h header file which is used for using input/output functions like scanf,printf etc.This header File is by default comes with C compiler so if even we don't include it will work fine.but is recommended to include it for increasing readability of program.
- In 2nd line of our code We have written int main().main() is special function in C because the execution of the program starts from main() function and since if don't define main() then the program will not be executed.We can define main() in our program only one once and in int main() int is the return type of the main() this mean that main() function can return integer type value.In C the statement of the particular function is enclosed within curly braces {}
- In 5th line of our code We are printing hello world.Here Import to notice is why we have enclosed Hello world within double inverted comma " " so the answer is whenever we have to print the statement as it is then we should enclose it in a double inverted comma " " and when we have the value of particular variable then we should write it directly with format specifier enclosed in " ".
- the last statement of figure 1.1 return 0 in the main function means that the program executed successfully. return 1 in the main function means that the program does not execute successfully and there is some error. In user-defined function. return 0 means that the user-defined function is returning false.
Fig 1.2
- What is format specifier ?
- %c (char)
- %d (int)
- %f (float)
- %lf (double)
- %u (for printing address of variable)
If you any have doubt,suggestion regarding this post or website then feel free to share with us.
If you have learned something new from this post then share this post with your family and
friends.
friends.
Happy Learning :)😎
Tags:
c hello world example
hello world algorithm in c
hello world in c hackerrank
hello world in objective c
hello world in turbo c
what is hello world in coding
This is explained in very simple language. Thank you for that
ReplyDeleteSir Please Fix Your Release Date Of Blog. Or set a Particular Period of Posting a Blog. Because We Are Waited Everyday. Nice Explanation 👍👌
ReplyDeleteYou are doing such a great work bro,keep it up
ReplyDelete