### Need help with this loop displaying only negative numbers.

These are the guidelines:
 ``1234567891011`` ``````c= 3 + 10*k - k*k Here are the two functions: CrackCypher - this will contain the loop CheckAnswer - this will check whether the value of k produces a negative value Make sure that check answer returns a bool value, and takes an integer input. Crack Cypher should return an integer as well. You should determine what integer value of k makes the cypher negative.``````

And this is my code thus far:
 ``123456789101112131415161718192021222324252627282930313233343536`` ``````#include int CrackCypher (int Guess); bool CheckAsnwer(int c); using namespace std; int main() { int Guess; CrackCypher(Guess); } bool CheckAsnwer(int c) { int k; c = 3 + (10*k) - (k*k); return c; } int CrackCypher (int Guess) { for (int k = 0; k < 21; k++) { int c; int CheckAnswer(c); if (c < 0) { cout << c; } } } ``````

I can do this perfectly fine without having to use functions, but since we have to use functions I have problems 'translating' it.
This is the code without using functions:

 ``1234567891011121314151617`` ``````#include using namespace std; int main() { int c; for (int k = 0; k < 21; k++) { c = 3 + (10*k) - (k*k); if (c < 0) { cout << c; } } }``````

I think that in this function

 ``1234567`` ``````bool CheckAsnwer(int c) { int k; c = 3 + (10*k) - (k*k); return c; }``````

variables shall be transposed as

 ``1234567`` ``````bool CheckAsnwer(int k) { int c; c = 3 + (10*k) - (k*k); return c; }``````
I tried that, but I still get nothing in return on the console.
I feel like my logic is wrong somewhere, but I'm not seeing it. :\
Topic archived. No new replies allowed.