One line or the other is not correct. The size of an array must be a constant, and you can't read into a const. If you want to do something like this, use malloc:
cin >> x; int *a = (int *)malloc(x*sizeof(int)); You can now use "a" as if it is an array of size x. Be sure to free the memory before "a" goes out of scope. Don On Jun 14, 9:39 am, amit <amitthecoo...@gmail.com> wrote: > is such a declaration correct: > cin>>x; > int a[x]; -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.