Counting operations in C++?
<p>I have 2 questions:
<strong>First</strong>:</p>

<pre><code>int a;
</code></pre>

<p>Is this statement considered as 1 operation or we must assign a value to the variable to consider it as 1 operation?</p>

<p><strong>Second</strong>:</p>

<pre><code>for(int i=0; i&lt;10; i++)
    for(int a=0; a&lt;n; a++)
       cout&lt;&lt;a;
       cout&lt;&lt;endl;
</code></pre>

<p>If we want to count the number of operations here we converted to while loop so it becomes:</p>

<pre><code>     int i=0//&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;1 operation.   d
     while(i&lt;10)//&gt;&gt;&gt;&gt;1              c
        {
          int a=0; //&gt;&gt;&gt;&gt;&gt;&gt;1         b
          while(a&lt;n)//&gt;&gt;&gt;&gt;&gt;&gt;1        a 
             {
                cout&lt;&lt;a;//&gt;&gt;&gt;&gt;&gt;&gt;1    a
                cout&lt;&lt;endl;//&gt;&gt;&gt;&gt;&gt;1  a
               a++;//&gt;&gt;&gt;&gt;&gt;&gt;&gt;1        a
             }
     i++;//&gt;&gt;&gt;&gt;&gt;1                    c
        }
</code></pre>

<p>the operations <strong>a</strong> will repeated <strong>n</strong> times in addition to the statement b,the we get the following equation : <strong>4n+1.</strong></p>

<p>Now operations <strong>c</strong> in addition to <strong>4n+1</strong> will repeated <strong>10</strong> times so the equation we get it :
<strong>((4n+1)+1+1)*10 + 1(operation d) = 40n+31;</strong></p>

<p>Is this the correct way to evaluate this code?</p>
