 <p>First, this line contains undefined behavior</p> <pre><code>print(++ptr,ptr--,ptr,ptr++,++ptr); </code></pre> <p>because it uses a variable that is part of an expression with side effect multiple times without reaching a <a href="http://en.wikipedia.org/wiki/Sequence_point" rel="nofollow"><em>sequence point</em></a>.</p> <blockquote> <p>In the code static keyword is used so i thought that each time it would take a different input.</p> </blockquote> <p>Presence or absence of <code>static</code> keyword makes no difference in this example, because the code never prints the value of the pointer, only the content of memory pointed to by that pointer.</p> <p>You can remove undefined behavior by moving each expression with side effects to a separate line, like this:</p> <pre><code>static int arr[]={97,98,99,100,101,102,103,104}; // static can be removed int *ptr=arr+1; // Start at index 1 printf("%d\n", *++ptr); // Move to index 2, prints 99 printf("%d\n", *ptr--); // Print 99, move to index 1 printf("%d\n", *ptr); // Print 98, stay at position 1 printf("%d\n", *ptr++); // Print 98, move to position 2 printf("%d\n", *++ptr); // Move to position 3, print 100 </code></pre> <p>(<a href="http://ideone.com/l110nj" rel="nofollow">demo</a>)</p> <p>Now the output is different (and correct):</p> <pre><code>99 99 98 98 100 </code></pre> <p>This is the output that you should expect to have based on the semantic of the pre-increment/decrement and post-increment/decrement operators.</p>