I know that there are posts about this all over the place probably but the way my course was taught was quite unique. The professor has his own compiler that uses a simplified c++ language, so I may not even be able to be helped but I'll give it a shot.
Basically I have to ask for an input of 6 elements into an array, check if the elements are unique or not using nested WHILE loops (I specify while loops because we were never taught for or do loops, the for loop being the most common loop i saw when i looked around for help on this), and output "unique" or "not unique". I for the life of me just can't figure out how to do this, specifically what the controls for the loops would be or how to nest them.
Here is a screenshot of the code I have so far (since I can't copy and paste with his compiler): https://gyazo.com/04f5f5b6a2fa5e5fe5120484a7d5f346
All i have is a loop to input values into the array.
not exactly I legitimately don't know what do which is why im on a forum. I asked in class and i got that i can loop through one element at a time in the outside loop and then for each of those elements, i can check it against all of the other elements in the array. However my brain just can't wrap around how exactly to do this, and anywhere else I looked for some idea of what to do they all used for loops.
Okay, so you have a loop to enter the numbers. The next step is to see which ones are unique. By the way, do you have to wait until the user enters all the numbers, or can you check for uniqueness as they enter them?
To check whether myArray[counter] is unique, you need to compare it against the previously entered numbers. With a for loop that might be:
1 2 3 4 5 6 7 8 9
int idx;
for (idx = 0; idx < counter; ++idx) {
if (myArray[idx] == myArray[counter]) break;
}
if (idx == counter) {
cout << "unique\n";
} else {
cout << "not unique\n";
}
Now just translate that for loop into a while loop and you're done.
i'm not sure. I'm assuming it would be after the user enters all the numbers. like i said the class was taught uniquely any type of online resource ive ever looked at for help just had things ive never seen before. I'm not even 100% sure of how to translate that for loop into a while loop. Also i was told there should be nested loops. So how you are showing me seems to be only a single loop which means thats not how i should be doing it.
edit: after looking at your solution and attempting to use it i don't even know how to implement that it actually doesn't make sense to me
You need to focus on what you are trying to achieve in general terms rather than what code you are going to write. That's why you're being pushed around by the wind going nowhere.
Ask yourself if you had 6 items sitting on a table, how would you test whether they are all unique. And then you need to decide what unique means in this.
Well, if it was me, I would
pick each one up in turn and compare it with all the others.
If that one is the same as any of the others then it isn't unique.
I'd continue through the collection of items until they've all been tested.
What you need to do now is refine that plan a bit if necessary so that you have a clear understanding of your solution prior to writing code for each of the plan steps.
BTW There are tutorials here with a section on control structures if, for, while etc with working examples. You need them! Your programming career will get a huge boost if you spend a couple of hours on that section. http://www.cplusplus.com/doc/tutorial/control/
You still don't get it. Have you read the tutorials? What is you plan? If you have one then post it. If you haven't then why are you wasting your time? This is not a homework site and your expectation that we will write your code is unfounded.
PS Your so-called professor isn't using any 'special' C++.