I need to make a for loop
without: using the math functions like pow, sqrt, etc. or an if-statement.
I can only use the basic arithmetic functions like +,-,*, and /
The for loop needs to display: 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192
as the result
How do I make it so my loop works?
This is what I have and it doesn't work...and I have no clue how to continue...any ideas??
1 2 3 4 5 6 7 8 9
|
k = 0; //k is an int and I have declared it in the beginning of my code
for( k = 0; k < 13; k++ )
{
printf ( "%d, ",k );
k = k * 2;
}
printf("%d", x);
|