# Can someone help me with Challenge?

#1

I read some of the threads on here… it only confused me more as to what I am doing wrong.

Below is my code… can someone please explain to me what I’m doing wrong and why it is wrong?
Thank you so very much!

#include <stdio.h>

{
float thirdangle = 180 - answer;
printf(“180 - %f is %f\n”, answer, thirdangle);
return thirdangle;

}

int main(int argc, const char * argv[])
{

``````float angleA = 30.0;
float angleB = 60.0;
float angleC = remainingAngle(angleA, angleB);
printf("The third angle is %.2f\n", angleC);
return 0;
``````

}

#2

[code]#include <stdio.h>

float remainingAngle(float angle1, float angle2); //<- This is a prototype. If prototypes are not used then the function definition must appear before main()

int main (int argc, const char * argv[])
{
float angleA = 30.0;
float angleB = 60.0;
float angleC = remainingAngle(angleA, angleB);// When calling the function, two arguments are passed (angleA and AngleB).

``````printf("The third angle is: %.2f\n", angleC);

return 0;
``````

}

// function definition
float remainingAngle(float angle1, float angle2) // Two arguments are defined. The value of angleA is stored in angle1 and the value of angleB is stored in angle2
{
float angle3 = 180 - (angle1 + angle2); //Now we do the math, angle3 gets the answer.
return angle3; // angle3’s value is returned back to the calling function and stored in angleC.
}[/code]
Mitch

#3

Thanks Mitch… I don’t understand what you posted But I’ll read through the chapter again and see if it makes sense to me.

I think I see what I’m doing wrong… but I don’t know ‘why’ it’s wrong.

#4

The definition of the function remainingAngle says that the function returns [b][color=#FF0000]void[/color]/b but it has a return statement with a value.

It should be defined like this (with the return value type as being float not [color=#FF0000]void[/color]):

``````float remainingAngle (float answer)
{
float thirdangle = 180 - answer;
printf("180 - %f is %f\n", answer, thirdangle);
return thirdangle;
}``````

#5

thanks… that has helped. I appreciate it…

#6

Yes, that is a good start but there is still a problem with the line:

float angleC = remainingAngle(angleA, angleB);

You are sending two arguments to a function that is defined as only needing one

The function needs to accept two arguments to meet the challenge requirements.

Mitch

#7

Thanks again… that was another problem I was seeing, but I couldn’t tell ‘why’ it was throwing up the error. Now I understand.

Thank you very much!
Doug

#8

Thanks for the help with this challenge. I was so close to getting it but had one little mistake.