Friday, 2 November 2012

ESCAPE SEQUANCE

# An escape sequances starts with a backslash and followed by 1 or more special characters as follows:

=> \n -for newline
=> \t -for horizontal tab
=> \a -for sound alert
=> \\ -for notes(will not effect the program)
=> \" -double coute.use to print double quote character

EXAMPLE:
#include<stdio.h>
void main(void)
{
printf("\a\a\Hi! Welcome to Programming..:)\n");
printf("Thanks for using C++\a\n")
}  

example of define program


#include <stdio.h>

#define X1  b+c

#define X2  X1+X1

#define X3  X2*c+X1-d
 
#define X4  2*X1+3*X2+4*X3

main( )

{

  int b=2;

  int c=3;

  int d=4;

  int e=X4;

  printf(" %d  %d  %d  %d  %d ", e, X1, X2, X3, X4);

  return 0;
}

Thursday, 1 November 2012

 A First C Program
// A first C  program 

#include <stdio.h> 



//(this is header)

main( )

{

  printf( “Welcome  to C!\n”);

  printf( “Thank you for using

 me!\n”);

  return 0;

}
Basic Structure of C program


#main( )  - Every program must have a main( ) function and it is a first function that will be called.

The main( ) function is the one to which control is passes when the program is executed


•{ }  These are known as braces or curly brackets. 


•The opening curly brackets indicates that a block of statements is about to begin. 
 
•The statements  of the functions are enclosed in these curly brackets.
  

•The closing curly brackets terminates the block of the statements.
 




Basic Structures and Program Life Cycle




Basic Structure of C program  
• 
All C  programs consist of the following
 
 elements:

#preprocessor directive


main( )

{

statements;

}