main()
{
/*.......................printing begins............*/
printf(" sample program");
/*.......................printing ends.............*/
}
The main() is a special function used by C to tell the computer where the program starts.Every program must have exactly one main function.If we use more than one main function, the compiler cannot tell which one marks the beginning of the program.The empty parentheses immediately after main indicates that the function main has no arguments(or parameters).
The opening brace '{' indicates beginning of main and the closing brace '}' indicates the end of the function.All the statements between the opening brace and ending brace indicate the function body.The function body contains a set of instructions to perform the given task.
The lines beginning with /* and ending with */ are known as comment lines which are used to enhance the readability and understanding of a program.Comment lines are not executable statements and therefore these lines are ignored by the compiler while executing a program.
The printf is the only executable in the given program.printf is a predefined function in the standard C library.For printing in the next line or start printing in a new line the printf statements should be appended with /n before the statement to start line and after the statement to start from the next line after the statement that is stated in the printf statement.
The general format of simple C program is
main() <--------------------------- function name { <----------------------------------- start of program ............ ............<============== program statements ............ } <----------------------------------- end of program
Monday, December 7, 2009
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment