Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

I am stumped. How to: Add two floats?

I am currently taking the functions challenge and I am stumped on adding the floats together, I know it is just a matter of syntax. This is my code. Please in the reply tell me what I need to do. Thank you.

void addtwo() int main() { } return 0; int addtwo

return 0; void addtwo( { float chicken = 24; float steak = 12;

chicken + steak; printf("24 + 12 = .\n");

}

1 Answer

Stone Preston
Stone Preston
42,016 Points

all you need to do is implement the function. you dont need the main method, and you dont need to define a function prototype or any variables.

below is a shell of what your function implementation should look like:

returnType functionName(dataType parameterOne, dataType parameterTwo) {

    return something;

}

the challenge tells you what to name the function, the data type of the arguments, and what it should return (it needs to add the parameters passed in to the function and return that sum). since the arguments need to be floats and you are adding them together you know the return type needs to be a float as well