how do you put the values in a while loop into an array
How do you put the values of variable a in this loop into an array?
int a=2;
while(a<100){
a=2*a;
}
Then I will suggest, using a
for loop:
1 2 3 4 5 6 7 8 9 10
|
#define MAX 100
int array[MAX]
int a=2;
for(int i=0;a<MAX;i++)
{
array[i]=a;
a*=2;
}
|
So much memory wasted right?
Still thinking of a way to solve that......................................................YES!...maybe vectors?
Topic archived. No new replies allowed.