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

James Young
James Young
775 Points

please help

Hey can anyone please help me out, I am a little confused here and would really appreciate it if someone could help explain this to me. Thanks guys

functions.c
int add_Two(int a + int b);
int main ()
{
  float a = 2.1416;
  float b = 3.7474;
  printf("%f + %f", a, b);

  Return 0;
}

2 Answers

Roberto Alicata
PLUS
Roberto Alicata
Courses Plus Student 39,959 Points

There are several errors in your code.

First the function name must be addTwo and not add_Two.

Then the challenge asks only to implement the function addTwo() not the main() function.

STEP 1 : It said that this function must return a float ....

float addTwo()

STEP 2: ..and it accepts 2 float parameters.

float addTwo(float a, float b){ }

STEP 3 : The function returns the sum of the two parameters.

float addTwo(float a, float b){
  return a + b;
}
James Young
James Young
775 Points

Hey Roberto I just wanted to say thank you for taking the time out of your day to help out someone in need. I am new to programming, and although trying to learn my first language is a bit confusing, I really am glad there are people like you here to help me out when I get stuck.

I hope you have a great day, thanks again!

James