Question: I have to display the records based on the integer value in an array. For instance, if I have an array i.e.

```
2, 3, 5, 3, 6, 8, 10, 1, 9, 7

```

I would need to display 3 and 5 based on the integer 2. Then it should display 6,8 and 10 based on integer 3 and then 9 based on 1. So my display array would be:

```
3,5
6,8,10
9

```

So far, I haven't been able to form any algorithm/code.. How to proceed on this one?

Answer: 
tested it with your given array...

```
void display_records(std::vector<int> vi) {
    int tmp = 0;
    int index = 0;
    for(int i=0;i<vi.size(); i++){

        for(int j=1;j<=vi[i];j++){
            index = i + j;
            tmp = vi[index];
            if((i+j) < vi.size()) {      //to prevent it going out of range
            std::cout << tmp << " " ;
            }
        }
        i = i + vi[i];
        std::cout << std::endl;
    }
}

```
Try something like this: (i am not sure if i understood your question) (not tested)

```
void displayRecords(int* vect, int size, int val)
{
    for(int i=0; i<size; i++)
        {
            if(vect[i]==val)
                {
                    int tmp = val;
                    int j = i + 1;

                    while(tmp && j != size)
                    {
                        std::cout<<vect[j]<<" ";
                        j++;
                        tmp--;
                    }

                    break;
                }
        }
}

```