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

wilsonkwan
wilsonkwan
3,174 Points

Failed run the code on the console

sorry guys, i keep failed to run the code on the console for this exercise.

I'd compile the code myself which has no error.

-- float addTwo (int x, int y); int main() {

int a = 10;
int b = 20;

printf ("add Two is %.2f\n", addTwo(a,b));
return 0;

}

float addTwo (int x, int y) { return x + y;

}

output: add Two is 30.00

2 Answers

Edit: Forgot the arguments were floats too.

Hi Wilson,

You're doing too much for the challenge. You're not supposed to write the main function.

Only the implementation of the addTwo function which is the last part of your code.

float addTwo (float x, float y) {
    return x + y;
}
wilsonkwan
wilsonkwan
3,174 Points

Hah! I"m learning the hard way ;)