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 trial

iOS Objective-C Basics (Retired) Functional Programming in C Functions

Steven Hubbard
Steven Hubbard
490 Points

defining return type as float

in this example i keep getting error that i'm not defining return type as float. I'm not sure how to do that, and don't remember it in the lessons. Please help!

int addTwo(float a, float b); int main() {

float number_1 = 23.2;
float number_2 = 45.6;

printf("addTwo is %f", addTwo(number_1, number_2));

return 0;

}

int addTwo(float a, float b){

return a + b;
Navid Mirzaie Milani
Navid Mirzaie Milani
6,274 Points

your function is an int ;) and you can't return a float ;)

it should be float addTwo(float a, float b);

Steven Hubbard
Steven Hubbard
490 Points

Thanks, i figured it out about 1 min after i wrote that. Dumb mistake. Thanks for help:)