ExamVeda
Login
Home
This question belongs to C Program C Fundamentals
C Fundamentals
?

What will be printed after execution of the following program code?
main()
{
      printf("\\nab"); 
      printf("\\bsi"); 
      printf("\\rha"); 
}

Answer & Solution
Correct Answer: Option D
\\n - newline - printf("\\nab"); - Prints 'ab'
\\b - backspace - printf("\\bsi"); - firstly '\\b' removes 'b' from 'ab ' and then prints 'si'. So after execution of printf("\\bsi"); it is 'asi'.
\\r - linefeed - printf("\\rha"); - Now here '\\r' moves the cursor to the start of the current line and then override 'asi' to 'hai' .
Examveda
Question posted by Examveda
Community

Join the Discussion

15 Comments
Sofiya Rukadikar
Sofiya Rukadikar 2 years ago
a back slash written with escape seq chars helps to print n itself and others so the output should be nabbsirha
Gajanand Prajapat
Gajanand Prajapat 4 years ago
n not for new line for new line
only single slash
Golam Muktadir
Golam Muktadir 6 years ago
Wrong answer set in option. It may option E
Sakshi Sinha
Sakshi Sinha 6 years ago
sir i think it is not correct ans correct ans is option-e
Harshini Mahankali
Harshini Mahankali 8 years ago
i think it is option e
Harshini Mahankali
Harshini Mahankali 8 years ago
how it is possible

Yasmin Khan
Yasmin Khan 8 years ago
This is your correct program

main()
{
printf("nab"); /* n for newLine */
printf("bsi"); /* b for backspace */
printf("rha"); /* r moves the cursor to the start of the current line*/
}

We are kindly informing you to use single backslash ( ) instead of double backslash ( )
Swarnava Chakraborty
Swarnava Chakraborty 8 years ago
main()
{
printf("
ab");
printf("si");
printf("
ha");
}
answer is- E because output is -
absi
ha
_________________________________________
main()
{
printf("
ab");
printf("si");
printf("
ha");
}

answer is- D because output is - hai
Deepak Kumar
Deepak Kumar 8 years ago
Sir correct answer is (e)none of these
Bawiha Tlau
Bawiha Tlau 9 years ago
answer is E:none of these
Awais Gujjar
Awais Gujjar 9 years ago
when cursor goes to start of line only ha should b printed but not hai
Ramya Setti
Ramya Setti 9 years ago
main is not a keyword bcz of its function
Ankita Awasthi
Ankita Awasthi 10 years ago
answer will be e)none of these
Ankita Awasthi
Ankita Awasthi 10 years ago
answer will be e)none of these
Prakhar Khanna
Prakhar Khanna 10 years ago
answer of this question should be (E) none of these
bcause on execution of this code o/p comes out to be "ha"