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 ( 11 )

  1. Harshini Mahankali
    Harshini Mahankali :
    10 months ago

    i think it is option e

  2. Harshini Mahankali
    Harshini Mahankali :
    10 months ago

    how it is possible

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

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

  5. Deepak Kumar
    Deepak Kumar :
    2 years ago

    Sir correct answer is (e)none of these

  6. Bawiha Tlau
    Bawiha Tlau :
    2 years ago

    answer is E:none of these

  7. Awais Gujjar
    Awais Gujjar :
    2 years ago

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

  8. Ramya Setti
    Ramya Setti :
    2 years ago

    main is not a keyword bcz of its function

  9. Ankita Awasthi
    Ankita Awasthi :
    3 years ago

    answer will be e)none of these

  10. Ankita Awasthi
    Ankita Awasthi :
    3 years ago

    answer will be e)none of these

  11. Prakhar Khanna
    Prakhar Khanna :
    4 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