Answered Questions

  • Spiral Structure

    Write a program for generating a spiral structure of N number.For example: If N= 4 then the structure will be as follow-1 24 3 If N=5, then the structure will be as follow- 1 25 4 3 If N=9, then the structure will be as follow-7 8 96 1 25 4 3 If N=15, then the structure will be as follow-7 8 9 106 1 2 115 4 3 12 15 14 13 If N=18, then the structure will be as follow- 7 8 9 10 6...

  • Register Relation

    Why p++ is faster than p+1?

    Star Read Best Answer

    Editorial / Best Answer

    sahasranaman  

    • Member Since Jul-2009 | Jul 1st, 2009


    p++ is faster because on compilation, it gets translated to three machine instructions, where as p=p+1 needs four machine instructions. All machine instructions take the same time.

    For p++, the instructions are:
    mov ax,
    inc ax
    mov,
    ax

    For p = p+ 1, the instructions would be,
    mov ax,
    mov bx, 1
    add bx
    mov,
    ax

    This is why p++ is faster than p+1