Need help with this loop displaying only negative numbers.

These are the guidelines:
1
2
3
4
5
6
7
8
9
10
11
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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>

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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>

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;
            }
        }
}


Help please?
I think that in this function

1
2
3
4
5
6
7
bool CheckAsnwer(int c)
    {
        int k;

        c = 3 + (10*k) - (k*k);
        return c;
    }


variables shall be transposed as

1
2
3
4
5
6
7
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.