confused on how my code work and want to understand the logic in it
<p>Please dont discourage this question..I am very new to c++ and really want to understand the code I work on.</p>

<pre><code>// bintodec.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

int main(){
        string inp;
        int dec = 0;
        char base;
        cout &lt;&lt; "Input a number: ";
        cin &gt;&gt; inp;
        cout &lt;&lt; "Input the base your number is in: ";
        cin &gt;&gt; base;
        for(int i = inp.length()-1, j = 0; i &gt;= 0; i--, ++j) dec += (inp[i]-48) * pow((float)base-48, j);
        cout &lt;&lt; "Your number in base 10 is: " &lt;&lt; dec &lt;&lt;endl;
        system("pause");
return 0;
}
</code></pre>

<p>I really want to understand how this FOR LOOP runs the INPUT NUMBER and BASE, to then get an answer.</p>

<p>so lets say I INPUT 110 BASE 2 PRINT: 6</p>

<p>*How the for loop is doing it</p>

<p>thanks all!</p>
