I think I am on the right track now.
I wrote and Algorithm but it may not be the most efficient way to write it.
1. int A, B, result;
2. Ask for first number (A)
3. Ask for second number (B)
4. while B > 0
5. Add result to A
6. decrement B
7. cout << "The result is: " << result << endl;
8. STOP
Now my code
Code:
#include <iostream>
using namespace std;
int main()
{
int A, B, result = 0;
cout << "Enter first number:" << endl;
cin >> A;
cout << "Enter second number:" << endl;
cin >> B;
while( B > 0 )
{
result += A;
B--;
cout << "The result is: " << result << endl;
}
}
Ok, I am getting the correct answer but is it supposed to do this?
Code:
Say A = 2 and B = 5
The result is: 2
The result is: 4
The result is: 6
The result is: 8
The result is: 10