[Solved] Too many arguments to function call, What do I do?


In your function definition

float remainingAngle(float answer)

the function remainingAngle() accepts one parameter.

OTOH, in your function call

remainingAngle(angleA,angleB);

you’re passing two arguments.

The supplied argument number and type should match with the parameter list in function definition.


That said, your code is wrong.

  • Point 1. Your local variables will shadow the global ones. Maybe that’s not what you want. Change

    float angleA = 30.0;
    float angleB = 60.0;
    

    to

     angleA = 30.0;
     angleB = 60.0;
    
  • Point 2. The function

    float remainingAngle(float answer)
    {
        float answer= angleA+angleB;
    //redefinition of answer
     return 0;
    }
    

    is logically wrong. It should rather be

    float remainingAngle(void)
    {
        float answer= angleA+angleB;
        return answer;
    }
    

    and should be called like

    float angleC = remainingAngle();
    

AFTER EDIT:

as per your requirement, you can do

float remainingAngle(float angleA, float angleB)
{
    float answer= angleA+angleB;
    return answer;
}

However, this makes the global variables useless.

solved Too many arguments to function call, What do I do?