int game = 3;
int ckenonum;
const int hkenostore = 4;
int hkeno[hkenostore];
const int ckenostore = 4;
int ckeno[ckenostore] = {1,2,3,4};
bool kenopass = false;

for(int hkenostore = 1; hkenostore<4; hkenostore++)
{
	do{
		cout<<"Please enter a unique number between 1 and 15 (" << hkenostore << " of 3)\n";
		cin>>hkeno[hkenostore];
		if(hkenostore>=2)
			if(hkeno[1] == hkeno[2] || hkeno [1] == hkeno[3] || hkeno[2] == hkeno[3])
				cout<<"You can't have same numbers! Please enter a different one...\n";
		else if(hkeno[hkenostore] >= 1 && hkeno[hkenostore] <= 15)
								kenopass = true;
		else
			{
			cout<<"Invalid Input! Please Try Again!\n";
			cin.clear();
			cin.ignore();
	      }
							
	}while(kenopass != true);
}

I'm having issues with getting the input to read properly. Ideally, when user inputs a number into [1], then into [2], if they are equal should ask for 2 again, and so on with [2] and [3] and [1] and [3]. But it seems to be stuck on [1] regardless of any integer input. Any pointers?

I think one of the problem is on your variable* declaration...

Your code is hard to read but your problem is in line 15, your using the array and it hasn't event been initialized it. Usually when you use an array, you you use hardcoded index when you want to access all values. What you are looking for is something like so:

int main(){
 const int size = 4;
 int values[size] = {0}; //set all values to 0;
 for(int i = 0; i < size; ++i){
     int input = 0;
     cin >> input; //get user input
     //check if it matches any previously inputted values
      bool isUnique = true;
     for(int j = i - 1; j >= 0; --j){
           if(input == values[j]){ //if current value is equal to the newly inputted value
               isUnique = false; //set state to false
               break;     //exit out of this for loop;
           }
     }
    if(isUnique){ //if is unique, save it
         values[i] = input; 
     } else{
            cout << "\nError value is not unique\n";
            //reset counter
             --i;
     }
 }
}
commented: Amazing, Very Helpful, totally opened my mind to new way of coding +1

firstPerson, that code you wrote is mind blowing to me.
I would never have thought of using a second for loop to check the input before assigning the input into the array.

maybe because this is my first programming class, but now you've given me a brand new outlook on how to write future code.

THANK YOU

firstPerson, that code you wrote is mind blowing to me.
I would never have thought of using a second for loop to check the input before assigning the input into the array.

maybe because this is my first programming class, but now you've given me a brand new outlook on how to write future code.

THANK YOU

I'm glad it helped. Good Luck.

how to create a program that will identify the parts of a calculator by using array... plss answer this ,, i need this after december,,,thnks

plsss. answer this, i need now,,... just complete the program,, row is row ,col is column
just comput the sum of all elements of the array

package pkg2darray;
public class Exercise1{
public static void main(String[] args) {
int[][] data={ { 3, 2, 5},
{1, 4, 4, 8, 13},
{9, 1, 0, 2},
{0, 2, 6, 3, -1, -8} };


for(int row=0; row< data.length; row++)
{
for ( int col=0; col< ???; col++)


System.out.println();
}
}}

1.make it largest element at the beginning::Exercise7A
2.make the largest element at the end::Exercise7B
3.make all the elements zero::Exercise7C

package array;
public class Exercise7{
        public static void main(String [] args){
        int[] array = {-20, 19, 1, 5, -1, 27, 19, 5};
        int row ;
       row = array[0];      
        for (int col = 0; col < array.length; col++){
            if (array[col]>row)
                row = array[col];}
        System.out.println("The maximum of this array is: " + row);
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.