# The best way to make two array functions distinguish guesses vs actual?

This is a discussion on The best way to make two array functions distinguish guesses vs actual? within the C Programming forums, part of the General Programming Boards category; In the program I am making the user will enter in 4 numbers ranging from 1 to 6. he will ...

1. ## The best way to make two array functions distinguish guesses vs actual?

In the program I am making the user will enter in 4 numbers ranging from 1 to 6. he will have twenty attempts to guess the correct numbers and in the correct order. to do that i need to make two void function arrays.

Code:
```void calculate correct numbers
correctnum++;
}
correctnum++;
}
correctnum++;
}
correctnum++;
}

void calculate correct locations /*something!*/
correctloc++;
}
correctloc++;

correctloc++;

correctloc++;
}```
however i was told the best way to do the "correct numbers" function is to put a for loop within a for loop, but i wasn't sure about that. i also was told that it was recommended to create a "dummy" function so that i don't get too high of a number when guessing the actual numbers. ie:

real- 1, 2, 3, 4
guess- 1, 1, 1, 4 ----> that should be two correct choices, the first guessed 1 and the 4.

any guidance would be greatly appreciated. thank you!

2. Sounds like a Mastermind game.
The correct function for "calculate correct locations" would be:
Code:
`void calculate_correct_locations(void) {`
(no spaces in the function's name)
The "calculate correct numbers" function needs more work.

3. Start by correctly defining your functions:
Code:
``` return_type func_name(arg_type arg, ...){
// do stuff
}```
makes a function named func_name, which takes arguments arg (of type arg_type), and returns some value of type return_type.

Originally Posted by nonoob
Code:
`void calculate_correct_locations(void) {`
(no spaces in the function's name)
and do the same for your correct numbers function.

As far as the for loop is concerned, is your problem that you don't know how to use a for loop, or just that you can't see how it is useful in this situation?

4. i understand for loops but the idea of doing a double for loop doesn't make sense in this situation. i wouldn't even know how to create that to be accurate. however i'm sure there are many other ways to avoid going that route so that i don't need to make another array with a dummy value. thanks.

5. The way I would do it is:
Code:
```for each guessed
for each actual
if guessed=actual
continue;
if board[guessed]=board[actual]
correct num++;
break;```