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

Join The Discussion

Comments ( 13 )

  1. Golam Muktadir
    Golam Muktadir :
    10 months ago

    Wrong answer set in option. It may option E

  2. Sakshi Sinha
    Sakshi Sinha :
    12 months ago

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

  3. Harshini Mahankali
    Harshini Mahankali :
    3 years ago

    i think it is option e

  4. Harshini Mahankali
    Harshini Mahankali :
    3 years ago

    how it is possible

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

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

  7. Deepak Kumar
    Deepak Kumar :
    3 years ago

    Sir correct answer is (e)none of these

  8. Bawiha Tlau
    Bawiha Tlau :
    4 years ago

    answer is E:none of these

  9. Awais Gujjar
    Awais Gujjar :
    4 years ago

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

  10. Ramya Setti
    Ramya Setti :
    4 years ago

    main is not a keyword bcz of its function

  11. Ankita Awasthi
    Ankita Awasthi :
    5 years ago

    answer will be e)none of these

  12. Ankita Awasthi
    Ankita Awasthi :
    5 years ago

    answer will be e)none of these

  13. Prakhar Khanna
    Prakhar Khanna :
    5 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