Saturday, 8 September 2018

Using Escape sequences

1. New line character(\n)

 \n is the new line character ,it moves the cursor to starting of next line.

Input:-

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Hello User");
printf("\nwelcome to C");
getch();
}


Output:-

Hello User
welcome to C



2. Tab character(\t)

\t is the horizontal tab character,it moves the cursor a tab width.

Input:-

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Hello \tUser");
printf("\nHi \tUser");
getch();
}

Output:-

Hello           User
Hi                User




3. Carriage return character(\r)

Input:-


#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
printf("Hello\r");
getch();

}

Output:-

Hello






















No comments:

Post a Comment