Friday, September 21, 2007

tech


expect the output
main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}

3 comments:

  1. got the ans as hai...
    can u explain how it has come

    ReplyDelete
  2. yaa here's the explanation..

    \n newline character: starts from 1st position of a new line

    \b backspace: moves one space back and then starts printing

    \r carriage return : this will prompt to the starting position of a current line

    printf("\nab"); output: ab

    printf("\bsi); output: asi /* moves one position left and executes of current line and b will overwritten*/

    printf("\rha"); output:hai /* the starting postion is "a" then "ha" will be overwritten on "as" and "i" remains the same ..hence teh output is "hai"

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete