0

Can someone tell me why this code doesn't work? The user inputs a number, let's say 10, and it's saved into an int num. I want to make a double datatype array which can store 10 or num amount of doubles. Why do I keep getting an error when I write it this way?

int num;
cin >> num;
double list[num];

Why is it the above three lines don't work but if I change num in last like to 10 or any other integer it works fine?

int num;
cin >> num;
double list[10];
Nayuki
  • 16,655
  • 5
  • 47
  • 75

0 Answers0