C is an procedure oriented programming language. For any begginer the word program is new.
Program: Set of instructions to be followed by machine or computer.
Instruction Examples: Arithmetic instruction like
a=b+c;
Semi colon here indicates end of instruction.
Collecting different variety of instructions into one name and executing it on machine. That one common name is noting but a procedure, function or method.
A C program can have n number of methods.
First sample program:
#include
int main()
{
// printf() displays the string inside quotation
printf("Hello, World!");//printf is a predefined library function
return 0;
}
First Line of program includes the header file . #include is a preprocessor command. This command tells compiler to include the contents of stdio.h (standard input and output) file in the program.
Header files in C contaions predefined function definitions. Example: printf();
main(): Function that starts the execution of program.
int: here it is return type of main()
A function can return any type of value.Here main is returning int so last line of program
contains return statment having default int value 0.
After compiling this program we get the filename.obj file. Linker performs linking and at the end we get filename.exe. This exe file is an executable file which is finally executed.