Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAbdulaziz Alahmari
2,537 PointsiOS Development - OBJ C - Functional Programming in C - Functions - Objective - Task
Trying to complete the challenge task in Functions. I have the code below. What am I doing wrong?
float addTwo(float a, float b);
int main() {
float a = .5;
float b = .5;
printf("%f\n", addTwo(a, b));
return 0;
}
float addTwo(float a, float b) {
return a + b;
}
2 Answers
Rodrigo Chousal
16,009 PointsI believe the instructions ask you to just write the implementation. This means that you have to assume that the declaration has been done for you. You also set values for the floats in main and printed the return value, which is unnecessary. Try this:
float addTwo (float a, float b) {
return a + b;
}
Abdulaziz Alahmari
2,537 PointsThank you very much.