Enter element 0 values: 10
Enter element 1 values: 20
Enter element 2 values: 30
Enter element 3 values: 40
Enter element 4 values: 50
Enter element 5 values: 70
In the last part, I just want the Element values to appear like this.
Element values are: 10 20 30 40 50 70
but its showing this instead :
Element values are: 70 70 70 70 70 70
So the last value, I entered is the one that repeatedly appears in the "Element values"
So please help me with this code, I cant seem to find the solution.
Thanks !
Line 8: This isn't standard C++ syntax, although some compiler support it. Array sizes must be known at compile time (when you compile the program). Ideally you should use a vector<int> instead, but for now, you might want to just get it working with the extension.
Line 9. When you create an array of 5 elements, the indexes are 0..4, not 0..5. So the test should be xox < arrsize
Line 13: You're storing into element number arrsize, which is actually out of bounds. So in your example, you store every number into num[5], overwriting the previous value each time. You need to store into num[xox].
Line 17: Same comment as line 9.
Line 19: Same problem as line 13: you're printing the same number each time.