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

Joel Muro
Joel Muro
2,884 Points

objective c functions and floats

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.)

need more clear it says i dont need to do a main function how can it work without assigning values to the float arguments

float addTwo(float a, float b);
float a = 24.564;
float b = 25.546;
printf("%f + %f\n", float addTwo(a, b));
return 0;
float addTwo(float a, float b) {

retun a + b;

what is wrong with my code?

float addTwo(float 2.53, float 3.45) {
 return float 2.53 + float 3.45; 


2 Answers

Hi Joel,

This is the closest that you have for what the challenge wants:

float addTwo(float a, float b) {

retun a + b;

You're missing the closing curly brace on that and you have a typo with retun

The challenge only wants the implemention or function definition as it is also known as. You don't need the function declaration or any of the other code you're trying to write.

Caleb Kleveter
Caleb Kleveter
Treehouse Moderator 37,862 Points

You should be using variables, not set number in your function, like this:

float addTwo(float a, float b) {
 return float a + float b;