Sunday, November 10, 2013

Improving the program. Taking topic help.

Improving the program

Now, we are going to add two new functions and few more to the program number 1.

Program 3:
Line 1:   /* The message program.
Line 2:     Written by: Me  Date:20 Nov 2013 */
Line 3:   #include <stdio.h>
Line 4:   #include <conio.h>
Line 5:   main()
Line 6:   {
Line 7:       clrscr();
Line 8:       printf(“One who makes no mistakes never makes anything.” );
Line 9:      getch();
Line 10: }

The first two lines in our program are comments. It starts with a combination of /*, and ends with */. In C “/*” is called opening comment mark and “*/” is called closing comment mark.

In line 7, we use clrscr() function. It is standard library function and used to clear the output screen.

In line 9, we use another standard library function getch(). It is used to pause the program output until user hit any key from the keyboard. The definition of these functions defined in the file “conio.h”. So, it becomes necessary to include it at the beginning of the program.

Line 10 indicates the end of the program.

How do we come to know that which function belongs to which header file (.h file)? It’s pretty simple. Just follow the procedure given below:


To know the prototype of the function, move the cursor of the first letter of the function (e.g. to know the prototype of the function getch() move the cursor to the first letter (i.e. “g”) and press Ctrl+F1. A help window appears. 


Note the name of header file and include it at the top of your program.



No comments:

Post a Comment