In this section we will learn that how to write first program in C programming language. hello world!!
#include"stdio.h"
int main() {
/* my first program in C */
printf("Hello, World! \n");
return 0;
}
Hello, World!
This is our first program in c Programming Language
#include"stdio.h"
"stdio.h" is basically a predefined standard input output library Which contain functions, marcos and variables.
#include"stdio.h" defines that it is including stdio.h library files with this program.
"printf" is a predefined function which is used to display something on the screen. In this program we want to display "Hello, World!" .
There are four types of functions in C :
1) function with arguments and return value
2) function with arguments and no return value
3) function with no argument and return value
4) function with no argument and no return value
'return value' means, the process or function after performing the certain operation gives you back a resultto the parent function from which it is being called. Actually, main is the parent function of all the functions in C. If we do not need any return value we use return type void but here we use return type int.
return 0 defines that, it will returns 0 .
First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.
After understanding this example, try to rewrite the same program without looking at the code. Then change some values or logic and run it again. This helps improve confidence and keeps learners engaged on the page for longer.