I am supposed to write a program that will read 25 positive numbers from the user and stores them in an array. The user can stop entering numbers by entering -1. The program must search print only the unique numbers the user has entered. It should also print out the total number of numbers entered along with the number of unique numbers entered. Any help you can give would be greatly appreciated! I'm very confused. It would be very helpful if you could point out exactly what I'm doing wrong. The program builds but the output doesn't look right. Thanks!
First thing I notice is that you have an array called input that holds 25 values, but then you try to write to input[25].
input[25] is out of bounds of the array, and writing to that location will result in undefined behavior (which is bad).
arrays start at index 0, so if 25 is the size of the array, indices go from [0] to [24].
Line 21: single quotes enclose individual characters. Double quotes enclose multi-character strings. You want a string here so it should be ", ".
Line 48: Your code will print "The unique numbers you entered were: " for each unique number. You want to print this outside the loop. The loop should only print the numbers and the string to separate them.
Thanks. The problem I'm having is that the code can't figure out which numbers are unique...it lists them all. For example when I enter 3, 4, 5, 5, 6, 7, 8, 8 it should tell me 4 are unique and they are 3, 4, 6, 7