Here's an extremely simplistic/mediocre way of doing it in C++, based on Aelfinn's posted.
Lets say you have array of strings A[40] with 40 cells, that looks sorta like the following?
A[0] = Question 1?
A[1] = Question 2?
A[2] = Question 3?
and, well, you get the idea. Now, basically create a second array, int B[40]. Also create a variable int so_far which will be an accumulator each time a question is asked.
So, lets say a random number 5 is chosen. First, look up A[5] and ask the question. Then, set B[0] equal to 5, and increment so_far by 1. Now, lets say a random number 8 is chosen. Look up A[8], ask the question, and set B[1] equal to 8, and increment so_far by 2. Each time a question is asked, do a linear search on B[0] through B[so_far - 1] to see if any of the values match up to 8. Make sense?