title: Difference in execution time in C and C++
body: <p>I recently found this site called codechef, where you can submit solutions to problems.
  I had submitted two answers for a question, one in C and the other in C++. Both codes are almost the same. But when the code I submitted in C was executed in 4.89s, the code I submitted in C++ was timed out (more than 8 seconds). How is this possible? Where does the time go?</p>
  <h2>The question was:</h2>
  <blockquote>
  <p>Input</p>
  <p>The input begins with two positive integers n k (n, k&lt;=107). The next n lines of input contain one positive integer ti, not greater than 10^9, each.</p>
  <p>Output</p>
  <p>Write a single integer to output, denoting how many integers ti are divisible by k.</p>
  </blockquote>
  <pre><code>Example
  
  Input:
  7 3
  1
  51
  966369
  7
  9
  999996
  11
  
  Output:
  4
  </code></pre>
  <h2>My code in C:</h2>
  <pre><code> #include&lt;stdio.h&gt;
     
   int main()  {
     
     int n,k,t;
     scanf(&quot;%d %d&quot;,&amp;n,&amp;k);
     int i,num=0;
     for(i=0;i&lt;n;i++)  {
       scanf(&quot;%d&quot;,&amp;t);
       if(t%k==0)  num++;
     }     
     
     printf(&quot;%d&quot;,num);
      
     return 0;
   }
  </code></pre>
  <h2>My Code in C++:</h2>
  <pre><code> #include&lt;iostream&gt;
    
   using namespace std;
     
   int main()  {
    
     int n, k, t,num=0;
     cin&gt;&gt;n&gt;&gt;k;
     for(int i=0;i&lt;n;i++)  {
       cin&gt;&gt;t;
       if(t%k==0)  num++;
     }
    
     cout&lt;&lt;num;
     return 0;
   } 
  </code></pre>