If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Unique random numbers in an array

Below is my code for a program that is suppose to generate and display six unique random numbers (between 1 and 54). The issue seems to be in my check for duplicates. I know what I am doing wrong but can't seem to find a way to fix it. I think it is getting stuck in an endless loop because the way I have written it looks like it checks the first value against itself which will of course look like a duplicate everytime. I am relatively new to programming, but catch on quickly....just a point in the right direction would be of immense help. Thanks.

Re: Unique random numbers in an array

That's not how you write multiple conditions in C++. randomNum[1] is an expression by itself, so unless it's 0, the entire statement will always be true. The way you wrote the first check is the way you need to write them all.