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!
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 trial

Marcus Marshall
5,520 PointsCode Challenge
I'm just not sure how to complete this code challenge. I keep getting this error: expected unqualified-id { ^ 1 error generated.
and I can't figure out what is wrong

Marcus Marshall
5,520 Pointsint addTwo (int a, int b); {
int a = 36;
int b = 37;
printf("add Two %d\n", addTwo(a, b));
return 0; } int addTwo(int a, int b); { return a + b; }'''

Marcus Marshall
5,520 PointsI'm not exactly sure how to work markdown properly despite the "cheatsheet" so I apologized for the code being formatted weird.
2 Answers

Dino Paškvan
Courses Plus Student 44,107 PointsWell, first of all, the challenge asks for a function that returns the sum of two floats, not integers. The sum of two floats is also a float, so both the function and the parameters should be declared as floats.
You only need to make the function, you don't need to call it, and you don't need to define your own a
and b
. The purpose of a function is to be able to call it for any possible parameters it accepts, not just the predefined ones.
This is what that would look like:
float addTwo(float a, float b) {
return a + b;
}

Marcus Marshall
5,520 PointsThank you for your help
Dino Paškvan
Courses Plus Student 44,107 PointsDino Paškvan
Courses Plus Student 44,107 PointsCould you paste your code here, please?