Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Wednesday, August 31, 2011

C-39 : Example of Escape Sequence (\n)

\n is the example of  Escape Sequence.
It's used to print the newline character.
Note that ,\n doesn't appear in the output.
Place \n wherever you want to insert a new line in the output.

See the examples below :
(Eg:-1) :

#include<stdio.h>
#include<conio.h>
void main()
{
            clrscr();
            printf("This\nString\nwill\nbe\nprinted\nin\n8\nlines.\n");
            getch();
}

Output:
This
String
will
be
printed
in
8
lines
===========================================================================
(Eg :-2) :
#include<stdio.h>
#include<conio.h>
main()
            {
            clrscr();
            printf("This is the First Line of Output.");
            printf("But is this the Second\nline of Output?");
            getch();
            }

Output:
This is the First Line of Output. But is this the Second
line of Output?


===========================================================================
(Eg :-3) : 




#include<stdio.h>
#include<conio.h>
main()
            {
            clrscr();
            printf("In how many lines will the output\nof this program be printed?");
            getch();
            }



Output:
In how many lines will the output
of this program be printed?
===========================================================================
(Eg:-4) :


What will be the output of the program ?

#include<stdio.h>
#include<conio.h>
main()
      {
      clrscr();
      printf("\"\\n\", the teacher said,\"is used to  ");
      printf("insert a new line in a C string.\"");
      printf("\n\" I C,I C\",said the blind student.\n");
      getch();
      return 0;
      }

Output:


" \n", the teacher said, "is used to  insert a new line in a C string".
"I C,I C", said the blind student.

(An important point to remember :  ""(Double Quote) character is not an Escape Sequence ).
.


=========================================================================
Back to Home   &  C

C-38: Example for Nested IF

Example to demonstrate Nested IF :

Refer Find largest from given numbers also.



#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();

            printf("First Section\n");
            {
                 printf("Second Section\n");
                 {
                        printf("Third section\n");
                        {
                                    printf("Fourth Section\n");
                        }
                 }
            }
            getch();
}



Output:

First Section
Second Section
Third Section
Fourth Section
=========================================================================
Back to Home   &  C

C-37 : My first C Program

My first C Program ; To display a message


#include<stdio.h>
#include<conio.h>
void main()
            {
            clrscr();
            printf("My first Program!! \n");
            getch();
            }


Output :

My first Program!!




Refer To display a message also.

Note :
While using code block ....See the input code below :
(use file --> new empty file )
 

(No need to  use "clrscr" if u are using code block like software)
=========================================================================
Back to Home   &  C