user13536: I'm trying to write PORTB and PORTD in ATmega328P using byte system like this,
    //  PD7  PD6  PD5  PD4  PD3  PD2  PD1  PD0
    //  N     N    N    N    N    U    U    U
    //  7     6    5    4    3    2    1    0
    //======================================
    //  PB7  PB6  PB5  PB4  PB3  PB2  PB1  PB0
    //  X     X    1    1    1    1    1    1
    //  C     C    13   12   11   10   9    8
    //======================================
    //C-Crystal Pins/U-Un used/N-Used/X-unknown value

    byte pins[] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

    //uint16_t style1=1365; //10101010101
    //uint16_t style2=682;  //01010101010

    void setup() {
      for (int i = 0; i < 11; i++) {
        pinMode(pins[i],OUTPUT);
        PORTD=B00000000;
        PORTB=B00000000;
      }

    }

    void loop() {
      PORTD=B10101000;
      PORTB=B00101010;
      delay(1000);
      PORTD=B01010000;
      PORTB=B00010101;

    }

According to this , Port value should be swapped.
But, It's still remaining given value of the code before delay()
What is the problem in this code?

user3917: 
What is the problem in this code?

No problem, it does change the bits of port D and B from 0B10101000 and 0B00101010 to 0B01010000 and 0B00010101 respectively.
However, microseconds later loop() runs again and changes them back to  0B10101000 and 0B00101010 for a full second. 
To better see what's happening, add a second delay(1000); statement, placing it just before the closing brace.

13536: <p>I'm trying to write PORTB and PORTD in ATmega328P using byte system like this,</p>

<pre><code>    //  PD7  PD6  PD5  PD4  PD3  PD2  PD1  PD0
    //  N     N    N    N    N    U    U    U
    //  7     6    5    4    3    2    1    0
    //======================================
    //  PB7  PB6  PB5  PB4  PB3  PB2  PB1  PB0
    //  X     X    1    1    1    1    1    1
    //  C     C    13   12   11   10   9    8
    //======================================
    //C-Crystal Pins/U-Un used/N-Used/X-unknown value

    byte pins[] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

    //uint16_t style1=1365; //10101010101
    //uint16_t style2=682;  //01010101010

    void setup() {
      for (int i = 0; i &lt; 11; i++) {
        pinMode(pins[i],OUTPUT);
        PORTD=B00000000;
        PORTB=B00000000;
      }

    }

    void loop() {
      PORTD=B10101000;
      PORTB=B00101010;
      delay(1000);
      PORTD=B01010000;
      PORTB=B00010101;

    }
</code></pre>

<p>According to this , Port value should be swapped.
But, It's still remaining given value of the code before delay()</p>

<p>What is the problem in this code?</p>
 3917: <blockquote>
  <p>What is the problem in this code?</p>
</blockquote>

<p>No problem, it <em>does</em> change the bits of port D and B from 0B10101000 and 0B00101010 to 0B01010000 and 0B00010101 respectively.</p>

<p>However, microseconds later <code>loop()</code> runs again and changes them back to  0B10101000 and 0B00101010 for a full second. </p>

<p>To better see what's happening, add a second <code>delay(1000);</code> statement, placing it just before the closing brace.</p>
