 <p>Suppose you have an integer array</p> <pre><code>int Marks[1000]={22,32,12,..............}; </code></pre> <p>First of all you sort your array</p> <pre><code>int g,r,c; for ( r=0; r &lt;=999; r++) { for ( g=r+1;g&lt;=1000;g++) { if ( Marks[r] &lt; Marks[g] ) { c=Marks[r]; // these 3 statements swap values Marks[r] =Marks[g]; // in the 2 cells being compared Marks[g] = c; } } } </code></pre> <p>Now you find that largest number is Marks[0] and second large is Marks[1]</p>