One word: overflow. -- Nevermind.
What exactly is the problem you are having?
Last edited on
that looks fine to me,
int num =2;
2 * 2 = 4
4 * 4 = 16
16 * 16 = 256 or something
which is higher than 48, but because the do-while started as 16, the while evaluated as true... so it executes the formula . then prints
cout << 256 << endl;
then program ends....
there is no return statement however in int main().
remember to return 0;
EDIT:
i did however run this to check and the result was 64, not sure how that came about....
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <iostream>
using namespace std;
int main()
{
int num=2;
do
{
num *= 2;
}
while(num < 48);
cout << num << endl;
return 0;
}
|
Last edited on
woops :P
*faceplants keyboard*
Last edited on