C PROGRAM BASICS
main( )
{ /* This is the beginning */
printf("Welcome to the world of C");
}
The first line informs the system that the name of the program is main( ) and the execution begins at this line. The main( ) is a special function used by the C system to tell the computer where the program starts. Every C program must have exactly one main( ) function. If we use more than one main( ), the compiler cannot tell wich one marks the begining of program. The empty parenthesis immediately following the main indicates that the function main has no arguments. The opening brace { in the second line marks the begining of the function main( ) and the closing brace } in the last line indicates the end of the function. All the statements between these two statements form the function body. The function body contains a set of instructions to perform a given task.
In this case the function body contains two statements out of which the printf line is an executable statement. The lines begin with /* and ends with */ is known as 'comment line'. Comment lines are non-executable statements and therefore anything between /* and */ is ignored by the compiler.
printf is a predefined standard function for printing output. Predefined means it is a function that has already been written and linked together with our program at the time of linking. The printf function causes every thing between the starting and ending quotation marks to be printed out.
printf("Hello Guest\nWelcome to Program Logic");
The argument in the printf contains a combination of two characters '\n'. This combination is collectively called the 'new line character'. It causes the computer to go to the next line. Hence the above printf statement will output :
Hello Guest
Welcome to Program Logic
Link section (Header File inclusion section)
Definition section
Global declaration section
main ( ) function section
{
Declaration part
Execution part
}
Subroutines
The documentation section consist of a set of comment lines giving the name of the program and other details.
The link section provides instruction to link functions from system library.
The definition section defines all symbolic constants.
There are some variables that are used in more than one function, such variables are called global variables and are declared in the global declaration section outside of all the functions.
Every C program must have one main( ) function. This section contains two parts, declaration part and execution part. Declaration part declares all the variables used in the executable part. These two parts must appear between the opening and the closing braces. The program execution begins at the opening brace and ends at the closing brace. The closing brace of the main( ) is the logical end of the program.
The subroutine section contains all the user defined function that are called in the main( ) function.
In this case the function body contains two statements out of which the printf line is an executable statement. The lines begin with /* and ends with */ is known as 'comment line'. Comment lines are non-executable statements and therefore anything between /* and */ is ignored by the compiler.
printf is a predefined standard function for printing output. Predefined means it is a function that has already been written and linked together with our program at the time of linking. The printf function causes every thing between the starting and ending quotation marks to be printed out.
printf("Hello Guest\nWelcome to Program Logic");
The argument in the printf contains a combination of two characters '\n'. This combination is collectively called the 'new line character'. It causes the computer to go to the next line. Hence the above printf statement will output :
Hello Guest
Welcome to Program Logic
Basic Structure of a C Program
Documentation sectionLink section (Header File inclusion section)
Definition section
Global declaration section
main ( ) function section
{
Declaration part
Execution part
}
Subroutines
The documentation section consist of a set of comment lines giving the name of the program and other details.
The link section provides instruction to link functions from system library.
The definition section defines all symbolic constants.
There are some variables that are used in more than one function, such variables are called global variables and are declared in the global declaration section outside of all the functions.
Every C program must have one main( ) function. This section contains two parts, declaration part and execution part. Declaration part declares all the variables used in the executable part. These two parts must appear between the opening and the closing braces. The program execution begins at the opening brace and ends at the closing brace. The closing brace of the main( ) is the logical end of the program.
The subroutine section contains all the user defined function that are called in the main( ) function.



0 comments:
Post a Comment