Sample program
Printing a message
Consider the following message
#include
main()
{
...../* Printing begins here */
.....printf (“C is a very good programming language.”);
...../* Printing ends here */
}
The first line is a preprocessor command which adds the stdio header file into our program. Actually stdio stands for standard input out, this header file supports the input-output functions in a program.
In a program, we need to provide input data and display processed data on standard output – Screen. The stdio.h header file supports these two activities. There are many header files which will be discussed in future.
The second line main() tell the compiler that it is the starting point of the program, every program should essentially have the main function only once in the program. The opening and closing braces indicates the beginning and ending of the program. All the statements between these two braces form the function body. These statements are actually the C code which tells the computer to do something. Each statement is a instruction for the computer to perform specific task.
The /* .... */ is a comment and will not be executed, the compiler simply ignores this statement. These are essential since it enhances the readability and understandability of the program. It is a very good practice to include comments in all the programs to make the users understand what is being done in the program.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment