Vikas Yadav Visual C++ Trainer

Ekam – A smart way to put next step…

Some common rules for writing C program

Remember Some common rules for writing C program

  • Use all commands or statements in lower or small case.
  • After completion of a statement excluding main() or loops must insert ; (semicolon) as a statement terminator.
  • Don’t use/declare identifier or variable name same as statement name suppose int include; this is a wrong statement because include has a special meaning in the language.
  • Header Files or Preprocessor Directives contains references or links of library functions. That is built-in in the C language.

Suppose if you want to use a function clrscr() ; in the main function so must be declared on top # include other wise you could have an prototype error.

Some header files are as follows

  • Stdio.h
  • Conio.h
  • Dos.h
  • String.h
  • Stdlib.h

And many more header files are available in C…

void main(void)
Every C programs consists of one or more functions. No matter how many
functions there are in a C program , main is the one to which control is passed
from the operating system when the program is run ; it is the first function
executed. The word “void” preceding “main” specifies that the function main()
will not return a value. The second “void,” in parenthesis , specifies that the
function takes no arguments.
printf()
printf() is built-in function we can display with printf() any message, variable
value on screen/file/printer.
In printf() we can use many escape sequences and format specifies.

Escape sequences are special notations through which we can display our data
Variety of ways:

Some escape sequences and their functions are as follows:
Escape Sequence    Description                                                   Example

\n                        Perform line feed & Carriage return operation       printf(“A\nB”);

\t                        Prints a tab sequence on screen                          printf (“A\tb”);

\’                         Prints a single quote character on screen          printf (“\’a\’”);

\”                         Prints a double quote character on Screen                printf (“\”a\”");

\r                         Perform carriage return operation                         printf (“a\rb”)

\b                         Remove one character from left                          printf (“a\bHi!” );

Advertisement

September 12, 2009 - Posted by | C Language | , , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.