I need help in c++. How do you out put only 1 array that has a size of 10?
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; }
Comment out that first for loop and try it. It should be good.
error: 'i' was not declared in this scope line 26
I get this error for some reason
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; }*/ ```
Join our real-time social learning platform and learn together with your friends!