title: C / C++ Interview: Code Optimization
body: <p>I had an interview today. This question was to optimize the code below. if we will see the code below after for loop there are four steps of "if-else" follows. So, interviewer asked me optimize it to 3 if-else line. I have tried a lot. But could not able to find the solution. Even he told me if you know scripting language then, you can use them also. 
  Please help me in optimizing the same.</p>
  
  <pre><code>int main()
  {
      int i = 1;
      for(i; i &lt;= 100; i++)
      {
          if((i % 3 == 0 &amp;&amp; i % 5 == 0))
          {cout &lt;&lt; "PR\n";}
          else if(i % 3 == 0)
          {cout &lt;&lt; "P\n";}
          else if(i % 5 == 0)
          {cout &lt;&lt; "R\n";}
          else
          {cout &lt;&lt; i &lt;&lt;"\n";}
      }
  system("pause");
  return 0;
  }
  </code></pre>