Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (lemonhappy):

I need help in c++. How do you out put only 1 array that has a size of 10?

OpenStudy (lemonhappy):

This is the program I need help with // Example program #include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main() { const int ARRAY_SIZE =10; srand(time(0)); string Questions[ARRAY_SIZE]= { "What is 1+1?", "What is 1+2?", "What is 2+2?", "What is 3+2?", "What is 4+2?", "What is 4+8?", "What is 8+8?", "What is 8+9?", "What is 9+1?", "What is 9+2?"}; for (int i=0; i < ARRAY_SIZE; i++) { int index = rand() % ARRAY_SIZE; string temp=Questions[i]; Questions[i]=Questions[index]; Questions[index]=temp; } for (int i=0; i < ARRAY_SIZE; i++) { cout << Questions[i] << endl; } return 0; }

OpenStudy (rsmith6559):

Comment out that first for loop and try it. It should be good.

OpenStudy (lemonhappy):

error: 'i' was not declared in this scope line 26

OpenStudy (lemonhappy):

I get this error for some reason

OpenStudy (rsmith6559):

Like this? ``` /* for (int i=0; i < ARRAY_SIZE; i++) { int index = rand() % ARRAY_SIZE; string temp=Questions[i]; Questions[i]=Questions[index]; Questions[index]=temp; }*/ ```

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!