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

What am I doing wrong here?

was wondering if someone could tell me what I'm doing wrong?

functions.c
int addTwo (int a, int b) {

  int good = 34;
  int man = 23;
  printf("%d %d\n",good, man);
}
int addTwo () {
return a + b + 8;
}

2 Answers

Hey Bud,

So, basically the question asks you to have the return type of float from the sum of two float arguments. Since we know that our end result has to be a float then our "addTwo" function would have a "float" instead of an int to which you would also include "float" in the arguments inside the function.

// returnType addTwo( float args good,  float args man)

float addTwo(float good, float man) {
return good + man;
}

You had it, just a few changes here and there.

```<p>int addTwo (int a, int b) {

float good = 34; float man = 23; printf("%f %f\n", good, man); } float addTwo(float good, float man) { return good + man; }<p>```

what am i doing wrong?

Hey,

With the code you posted - you're calling two functions and trying to print one. The "int addTwo(int a, int b)" is not needed because you're not trying to return integer value with integer arguments. It's not asking you to print to the console so you don't have to worry about the printf statement; it's not needed. The last part about implementation is basically asking write the working code without actually filling it out- if that makes sense. So,don't worry about a = 1 or b = 2 etc, etc, just the code. It's more about learning the concept rather than writing a full on function. The code that I posted yesterday or this one will pass you to the next video.

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