How to solve this for-loop exercise in c++ (beginner). n + nx2 + nx2x2 +

#include <iostream>
using namespace std;

int main()

{
    int a,b,i,result;
    cout << " Enter a and b: " << endl;
    cin >> a >> b;
    result = a;                 // At 0 sec result is a
    for (i=1; i<=b; i++) 
    {
        result = result*2;      // Doubles the result at every second
        cout <<result<< endl;
    }
    return 0;
}

Leave a Comment