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
Jose Macias
1,545 PointsTrouble with Variables Code Challenge
When i do the variables code challenge on objective-C the 2nd task i do it correct but it says its not in the correct format??!! Help!!
Jose Macias
1,545 Pointshttp://teamtreehouse.com/library/variables-2
Thats the link but when i do it its all right but it says "its in the wrong format"
John W
21,558 PointsUgh... My account is having issues accessing code challenges, can you please include the follow two items:
- The problem statement in the code challenge. What is it asking you?
- Your rejected solution(s). What have you tried?
Without either, it is impossible for me to guide you in the proper direction.
Jose Macias
1,545 Pointswell the first task it says to type a float named "radius" with the value of 14.5,,,, I got that one right my response was float radius = 14.5;
The 2nd task was create a print statement and the output being " A ball with a radius of 14.5 inches" but when i try it says "its in the wrong format" and my response is...
printf("%f A ball with a radius of 14.5 inches.\n", radius);
help!
6 Answers
Jose Macias
1,545 Pointswell the first task it says to type a float named "radius" with the value of 14.5,,,, I got that one right my response was float radius = 14.5;
The 2nd task was create a print statement and the output being " A ball with a radius of 14.5 inches" but when i try it says "its in the wrong format" and my response is...
printf("%f A ball with a radius of 14.5 inches.\n", radius);
help!
John W
21,558 Points:) Now it is very clear what's wrong! If you follow this same format each time you ask a question, you can get answers much quicker!
printf replaces occurrences of %f, %d, %c, %s, %@, etc. (you get the idea) with the value of what follows the comma, hence, what you have there would produce this instead:
14.5 A ball with a radius of 14.5 inches.
Give it some thought, let it sinks in first. How would you make the number in A ball with a radius of 14.5 inches be dynamically replaced with the value of radius?
Jose Macias
1,545 Pointsthanks you helped me a ton!!!
Jose Macias
1,545 Pointsyou answer is still not helping!! can you just give me the answer
John W
21,558 PointsIt would be harmful if I have just given you the answer right away, there are many things to learn beyond this and most of the time you just have to figure it out as much as you can yourself. But here's something to get you closer:
You want to print out something like A ball with a radius of ??? inches, where ??? is the value of your variable radius, now use %f instead so ??? gets replaced by the proper value from radius. Your answer should look something like this:
printf("A ball with a radius of ....", radius);
If this is still not enough, you may want to watch the video again.
Jose Macias
1,545 PointsThanks now you helped it worked.. Thanks!!!
Alexander Valeev
406 PointsWhen I put this-- printf("A ball with a radius of %f inches.\n", radius); It rejects it. HELP
Jose Macias
1,545 PointsDON'T put inches after %f
Alexander Valeev
406 PointsThanks
Jose Macias
1,545 PointsGlad it helped!
Alexander Valeev
406 PointsRejected the function again. Sorry. float radius = 14.5; printf("A ball with a radius of %f.\n", radius);
Alexander Valeev
406 PointsStill rejected printf("A ball with a radius of %f.\n", radius);
Jose Macias
1,545 PointsWell not on the computer right now ask again tommorrow and I'll be glad to help!!
Alexander Valeev
406 PointsIf the help is still offered, I would be grateful to get it. Thanks.
Jose Macias
1,545 Pointsput this is printf("A ball with a radius of %f inches\n", radius);
Alexander Valeev
406 PointsThank you so much!!
Jose Macias
1,545 Pointsyour very welcome!!
Jason Cheung
2,327 PointsAns, Float radius = 14.5; Printf("%f radius.\n", radius); printf("A ball with a radius %f\n", radius); printf("A ball with a radius %f\n", radius);
John W
21,558 PointsJohn W
21,558 PointsCan you link the code challenge and tell us what you have tried that didn't work?