Printf MCQ 10 : Backslash Character in Printf



Printf Multiple Choice Questions  : Backslash Character in Printf


Question : Guess the output of Program

#include<stdio.h>
#include<conio.h>

void main()
{
clrscr();
char *str1="Indii";
char *str2="ian";
printf("%s\b\b%s",str1,str2);
getch();
}

Options :

  1. Indiiian
  2. ianindii
  3. Indian
  4. Indiian

[toggle title=”Output”]Indian[/toggle]


Switch to Printf MCQ Home :  Click Here


How and Why ?

  1. ‘b’ – Backslash Character Moves Cursor Position one Character Back
  2. In Printf there are two ‘b’ so It Moves Cursor Position on 4th Position  ‘i’ (Indii)
  3. After it Overwirte “ii” by “ian” and gives “indian”