Skip to main content
added 140 characters in body; edited tags
Source Link
ChrisG
  • 7.4k
  • 2
  • 17
  • 26

I have just started Pset3. I was going well untilluntil as per specification I read this "Re-write search in such a way that it uses linear search, returning true if value is in values and false if value is not in values. Take care to return false right away if n isn’t even positive." I

Re-write search in such a way that it uses linear search, returning true if value is in values and false if value is not in values. Take care to return false right away if n isn’t even positive.

I was like what am I suppose to do now? Still having no idea what to do I wrote this code in search function in helpers.c

bool search(int value, int values[], int n) { if (n < 0) { return false; }helpers.c

for (int i = 0 ; i < n; i++)
{
    if (values[i] == value)
    {
        return true;
    }
    else
    return false;    
}

}

bool search(int value, int values[], int n)
{
    if (n < 0)
    {
        return false;
    }
    for (int i = 0 ; i < n; i++)
    {
        if (values[i] == value)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}

But didnt gotdidn't get the needle, so the question here is? what am i supposeI supposed to do here? amAm i going in the right direction? anyAny help or hint would really be appreciated.

I have just started Pset3. I was going well untill as per specification I read this "Re-write search in such a way that it uses linear search, returning true if value is in values and false if value is not in values. Take care to return false right away if n isn’t even positive." I was like what am I suppose to do now? Still having no idea what to do I wrote this code in search function in helpers.c

bool search(int value, int values[], int n) { if (n < 0) { return false; }

for (int i = 0 ; i < n; i++)
{
    if (values[i] == value)
    {
        return true;
    }
    else
    return false;    
}

}

But didnt got the needle, so the question here is? what am i suppose to do here? am i going in the right direction? any help or hint would really be appreciated

I have just started Pset3. I was going well until as per specification I read this

Re-write search in such a way that it uses linear search, returning true if value is in values and false if value is not in values. Take care to return false right away if n isn’t even positive.

I was like what am I suppose to do now? Still having no idea what to do I wrote this code in search function in helpers.c

bool search(int value, int values[], int n)
{
    if (n < 0)
    {
        return false;
    }
    for (int i = 0 ; i < n; i++)
    {
        if (values[i] == value)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}

But didn't get the needle, so the question here is what am I supposed to do here? Am i going in the right direction? Any help or hint would really be appreciated.

deleted 3 characters in body
Source Link

I have just started Pset3. I was going well untill as per specification I read this "Re-write search in such a way that it uses linear search, returning true if value is in values and false if value is not in values. Take care to return false right away if n isn’t even positive." I was like what am I suppose to do now? Still having no idea what to do I wrote this code in search function in helpers.c

bool search(int value, int values[], int n) { if (n < 0) { return false; }

for (int i = 0 ; i < MAX ;n; i++)
{
    if (values[i] == value)
    {
        return true;
    }
    else
    return false;    
}

}

But didnt got the needle, so the question here is? what am i suppose to do here? am i going in the right direction? any help or hint would really be appreciated

I have just started Pset3. I was going well untill as per specification I read this "Re-write search in such a way that it uses linear search, returning true if value is in values and false if value is not in values. Take care to return false right away if n isn’t even positive." I was like what am I suppose to do now? Still having no idea what to do I wrote this code in search function in helpers.c

bool search(int value, int values[], int n) { if (n < 0) { return false; }

for (int i = 0 ; i < MAX ; i++)
{
    if (values[i] == value)
    {
        return true;
    }
    else
    return false;    
}

}

But didnt got the needle, so the question here is? what am i suppose to do here? am i going in the right direction? any help or hint would really be appreciated

I have just started Pset3. I was going well untill as per specification I read this "Re-write search in such a way that it uses linear search, returning true if value is in values and false if value is not in values. Take care to return false right away if n isn’t even positive." I was like what am I suppose to do now? Still having no idea what to do I wrote this code in search function in helpers.c

bool search(int value, int values[], int n) { if (n < 0) { return false; }

for (int i = 0 ; i < n; i++)
{
    if (values[i] == value)
    {
        return true;
    }
    else
    return false;    
}

}

But didnt got the needle, so the question here is? what am i suppose to do here? am i going in the right direction? any help or hint would really be appreciated

Source Link

Pset 3 Search what am i suppose to do?

I have just started Pset3. I was going well untill as per specification I read this "Re-write search in such a way that it uses linear search, returning true if value is in values and false if value is not in values. Take care to return false right away if n isn’t even positive." I was like what am I suppose to do now? Still having no idea what to do I wrote this code in search function in helpers.c

bool search(int value, int values[], int n) { if (n < 0) { return false; }

for (int i = 0 ; i < MAX ; i++)
{
    if (values[i] == value)
    {
        return true;
    }
    else
    return false;    
}

}

But didnt got the needle, so the question here is? what am i suppose to do here? am i going in the right direction? any help or hint would really be appreciated