Home / C Programming / C Fundamentals :: Discussion

Discussion :: C Fundamentals

  1. What will be printed after execution of the following program code?

    main()

    {

    printf("\\nab");

    printf("\\bsi");

    printf("\\rha");

    }

  2. A.

     absiha

    B.

     asiha

    C.

     haasi

    D.

     hai

    E.

     None of these

    View Answer

    Workspace

    Answer : Option D

    Explanation :

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


Be The First To Comment