Array as loop index

I want to know if its possible to make array as loop index. I have arbitrary number of summations and my sum is a function of various loop indices. I have done programming before in fortran and didn't find such option there. Highly appreciate your help.

Thanks
Last edited on
@anust

Sure it is. First, you declare an array. (Example..) int check_loops[4]={12,10,14,20} Then, when you need the loop for summations, you have..
1
2
3
4
for(int x=0;x<4;x++)// 1 for each of the four numbers in  check_loops[] array
  for (int i = 0;i< check_loops[i];i++)
{ // Questions go in here ...
}


Hope this helps
Last edited on
Thanks for your reply
Since I have never used c++, it'll take me sometime to understand your reply. I'll get back to you.
Topic archived. No new replies allowed.