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 trialhenrickfarias2
747 PointsFLOAT..!! it is not accepting my code, and I don't get what I'm doing wrong...
well, I've tried everything, and maybe it's just that I'm not quite understanding what I'm being asked for (English is not my first language...)
this is what they are asking:
"Implement a function named "addTwo" that returns the sum of two floats. The function will accept two float numbers as arguments. It should add the two arguments together, and return the result. (No need to write the main function. Just write out the implementation for the addTwo function.)"
I'll paste my code down here and if you could help me out a little I would seriously appreciate it.
float addTwo (float a, float b);
float a = 24;
float b = 35;
float result = a + b;
printf("a + b = %f\n", result);
return a + b;
thanks a lot...!!
2 Answers
Dino Paškvan
Courses Plus Student 44,108 PointsYou just need to implement the function, not add parameters to it or anything like that. And remember, the body of a function must be surrounded in curly braces:
float addTwo(float a, float b) {
return a + b;
}
Robert Bojor
Courses Plus Student 29,439 PointsHello,
You need to write a function that will add the two passed parameters. Something like this:
function addTwo(float a, float b) {
return a + b;
}
and then just call addTwo(1.2, 2.1);
henrickfarias2
747 Pointsthanks a lot, I was just complicating myself after having tried so many different things...
henrickfarias2
747 Pointshenrickfarias2
747 Pointsthanks a lot, I was just complicating myself after having tried so many different things...