How can I put a range of numbers in an array without typing in all the numbers. Like 0-24,25-49,50-74,75-100
I tried;
Is that a legal statement?Code:int x[] = {0-24,25-49,50-74,75-100};
any sugguestions?
Thanks
Printable View
How can I put a range of numbers in an array without typing in all the numbers. Like 0-24,25-49,50-74,75-100
I tried;
Is that a legal statement?Code:int x[] = {0-24,25-49,50-74,75-100};
any sugguestions?
Thanks
>How can I put a range of numbers in an array without typing in all the numbers. Like 0-24,25-49,50-74,75-100
You don't. Try either building a vector at runtime or using paired numbers for the minimum and maximum of the range:
Code:int x[] = {
0, 24,
25, 49,
50, 74,
75, 100,
};
Hey twm - chill on the sig man. Most people here are very cool and some of the best people you'll ever meet on a board. It's all good.
Usually you load an array from disk if you have a lot of numbers to put into it. Unfortunately there is no DATA like BASIC keyword that allows you to put data directly into the data segment and then retrieve it with a READ.
>Hey twm - chill on the sig man.
Joke...funny...laugh. :D
I'm not sure if this is what you wanted, but uhm, for loop?
Code:for(int i =0; i < max; ++i)
array[i] = i;
You could use a 2d array, something like:
Note I didn't test this codeCode:int array[4][25] ;
for (int x=0;x<4;x++)
for(int y=0;y<25;y++)
array[x][y] = y*(x+1);