I am unable to find my mistake, and i don't know what I am doing incorrectly. I can't get right the element part. I need to do a Load 10 integers into an array, then prompt the user for a number from 0 to 9. Display the element at the array position the user selects. For example:
Reading in: 77, 33, 88, 99, 22, 55, 11, 44, 66, 0
Enter a number from 0 to 9: 3
Element number 3 is 99
my code
PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/ http://www.cplusplus.com/articles/z13hAqkS/
Hint: You can edit your post, highlight your code and press the <> formatting button.
You can use the preview button at the bottom to see how it looks.
If you want your output to match your example then you have codded the program wrong.
Starting from the line cout<<"Enter a number from 0 to 9: "; and after the code needs to be reworked to match your example output.
What is the purpose of cin>>numbers[9];? I mean the one above the if statement. The "cin" here should be getting proper value for "i' to be used in the else block and there should be no input in the else block.
And in the else block the line cin>> numbers[i]; "i" has no usable value at this point.