Although even you are not familiar with the C keywords, Data types, operators, and Concepts but don’t need to worry.I have taken “Hello World” example just to explain basic framework of C language.
Our Task is to write a program to print “Hello World” on Console.So first you shall create CodeBlock project as I explained in the previous chapter.
int main(int argc,char *argv)
printf("Hello World"); /* output function */
Write this code on your CodeBlock editor and build(ctrl+f9) and run(ctrl+f10).
stdio.h: standard input-output library
This library contains all the input and output related function’s definition.Output function like printf() and input function like scanf() has its definition inside this library.
#(HASH) is used as a prefix with a keyword and these statements will first process by the compiler when we build the program.
so , #include<stdio.h> means include the stdio.
main() : entry function of c project
C function Syntax:
returnValue function_name(arg 1 , arg 2, … arg n)
/*body of function*/
see the below main function syntax:
structure of the main function is standard and the input passed inside the main is also predefined and optional if a programmer doesn’t need to pass any value from the outside world. If programmer need to pass input from the console at run time then it would be taken care by below parameters of the main function.
argc: Argument Count(Number of the argument passed by command line prompt)
argv: Pointer to the array of argument buffer which has input values.
Keyword Used in main()
int (return value) tells about the data type of the output of the main function.
printf() is an output function, defined in the stdio library will take “Hello World” as an input and will print same on console.
scanf() is an input function, also defined in the standard library, not use in above program(not required in this program), shall use when we have to give some input at runtime from outside.
return is the keyword used to return