function not working

Hello all,

I need to write a function to find the greatest divisor of a number besides itself. I can't understand why what I have written isn't working.
Any help would be great. Here it is.... (year is the number)

[code]
int third (int year, int i)
{
int largestdivisor;
for (i = year; i >= 0; i--)
{
if (year%i == 0)
break;
}
largestdivisor = year/i;
return largestdivisor;
}
[/code]

An error msg comes up saying "too few arguments to function `int third(int, int)"

Comments

  • : Hello all,
    :
    : I need to write a function to find the greatest divisor of a number
    : besides itself. I can't understand why what I have written isn't
    : working.
    : Any help would be great. Here it is.... (year is the number)
    :
    : [code]:
    : int third (int year, int i)
    : {
    : int largestdivisor;
    : for (i = year; i >= 0; i--)
    : {
    : if (year%i == 0)
    : break;
    : }
    : largestdivisor = year/i;
    : return largestdivisor;
    : }
    : [/code]:
    :
    : An error msg comes up saying "too few arguments to function `int
    : third(int, int)"

    Don't worry, i figured it out.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion