+ 1
https://code.sololearn.com/c6RF7KCO6FhD/#cpp #include <iostream> using namespace std; int main() { int foo [10] = { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19 }; // set them yourself int bar [10]; // use FOR loop to store them int counter = 1; for(int i = 0; i < 10; ++i) { bar[i] = counter; counter += 2; cout << bar[i] << endl; } return 0; } :::: OUTPUT :::: 1 3 5 7 9 11 13 15 17 19 There are a bunch of ways to do it. Here is two simple ways above. Since you're dealing with a small number, you could just set it yourself. Another way is to create your array and then use a FOR loop to set the values. Using the counter, we have the initial number and then just add 2 to it during each iteration (it'll always be odd/even depending upon starting number). Hope that helps. Let me know if you need further ways of doing it or if that'll suffice.
28th May 2019, 2:40 PM
AgentSmith