Examveda
Examveda

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

A. absiha

B. asiha

C. haasi

D. hai

E. None of these

Answer: Option D

Solution(By Examveda Team)

\\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' .

This Question Belongs to C Program >> C Fundamentals

Join The Discussion

Comments ( 14 )

  1. Gajanand Prajapat
    Gajanand Prajapat :
    2 years ago

    n not for new line for new line
    only single slash

  2. Golam Muktadir
    Golam Muktadir :
    3 years ago

    Wrong answer set in option. It may option E

  3. Sakshi Sinha
    Sakshi Sinha :
    4 years ago

    sir i think it is not correct ans correct ans is option-e

  4. Harshini Mahankali
    Harshini Mahankali :
    5 years ago

    i think it is option e

  5. Harshini Mahankali
    Harshini Mahankali :
    5 years ago

    how it is possible

  6. Yasmin Khan
    Yasmin Khan :
    5 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 ( )

  7. Swarnava Chakraborty
    Swarnava Chakraborty :
    6 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

  8. Deepak Kumar
    Deepak Kumar :
    6 years ago

    Sir correct answer is (e)none of these

  9. Bawiha Tlau
    Bawiha Tlau :
    6 years ago

    answer is E:none of these

  10. Awais Gujjar
    Awais Gujjar :
    6 years ago

    when cursor goes to start of line only ha should b printed but not hai

  11. Ramya Setti
    Ramya Setti :
    7 years ago

    main is not a keyword bcz of its function

  12. Ankita Awasthi
    Ankita Awasthi :
    7 years ago

    answer will be e)none of these

  13. Ankita Awasthi
    Ankita Awasthi :
    7 years ago

    answer will be e)none of these

  14. Prakhar Khanna
    Prakhar Khanna :
    8 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"

Related Questions on C Fundamentals