To print each manipulation you could do something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
using namespace std;
void pause();
int main()
{
int input;
int value;
//.....
cin >> input;
cout << "\nInitial value is: " << input;
for (value = input * 2; value < 100; value *= 2)//for each iteration, value will be multiplied by 2 until value is greater or equal to 100
{
std::cout << "\nValue is now: " << value;//prints on screen the variable value for each iteration of the for loop
}
//.....
return 0;
}
|
This is one way of doing it.
Output:
2[Enter]
Initial value is: 2
Value is now: 4
Value is now: 8
Value is now: 16
Value is now: 32
Value is now: 64
|
EDIT:
Watch out for the following things:
__In your for loop you created a new
int i
as an iterator, you don't actually need it since you want to
check if value is lower than 100. So it's more logical to have
value
as your iterator.
__In your for loop still, you don't want to increment your iterator by one since you don't want your
value to go like (2, 3, 4, 5, .... 99), you want your value (which is also your iterator) to double each
time. Hence the use of
value *= 2
and not
value ++
.
__Any time you want to print something you can use
cout << "Print me";
asuming
you are
using namesapce std;
, otherwise you'd use
std::cout << "Print me";