0

Is there a way to declare a series of variables like shown using a loop?

int n1,n2,n3,n4,n5,n6,n7,n8,n9,n10;
for (int i = 1 ; i <= 10 ; i++) {
    cout << "Enter number " << i << ": ";
    cin >> n(i);
}
2
  • 4
    int n[10]; for(int i = 0; i < 10; ++i) { cin >> n[i]; } perhaps? Commented Feb 28, 2021 at 18:08
  • 1
    Not possible, but also not necessary when you have arrays. Commented Feb 28, 2021 at 18:10

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.