hello people, im trying to write this program that subtracts 2 from each element of the array, the program works fine but it gives me a wrong answer for the last element. plz help
You're going out of bounds. Since your array is 10 long, the largest index you can use is 9. so cout << myArray[10] <<endl; has a good chance of crashing your program.
Now look at your while loop: For the last iteration x is 10. Let's see what this will look like: