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 trialOleksiy Ryabchuk
875 Pointssum of 2 floats func
what i do wrong? mb i need to return somth in body of main func?
float addTwo(float a, float b); //declare type name args
{
float a = 15.2; //declare variables
float b = 1.5;
printf("the sum is %f \n", addTwo); //print the result
return 0;
}
float addTwo(float a, float b) { // func that make a sum
return a + b;
}
1 Answer
Gabe Nadel
Treehouse Guest Teacherint main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... NSLog(@"Hello, World!"); }
float addTwo(float a, float b); //declare type name args
float a = 15.2; //declare variables
float b = 1.5;
float addTwoResult = addTwo(a, b);
//create a variable to hold the result, call the function, set teh variable value to that result.
printf("the sum is %f \n", addTwoResult); //print the result
return 0;
}
float addTwo(float a, float b) { // func that make a sum return a + b; }
Oleksiy Ryabchuk
875 Pointsthanx it works, now i understand mistake :)
Oleksiy Ryabchuk
875 PointsOleksiy Ryabchuk
875 Pointsjust create simple func like this
float addTwo (float a, float b) { return a+b; }
add pass the challenge, what is my problem with 1st function i tried it in xcode and have massage a and b is undefined but i declare it