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 trialIgor Kletsov
7,556 PointsChallenge task 3 of 3
Task-3
Print the length of the array real_numbers using the sizeof() function. Your output should look like the following: Array real_numbers can store x items.
his is how I did it:
float real_numbers [] = {1.1, 2.2, 3.3, 4.4, 5.5};
printf ("Array real_numbers can store %ld items", sizeof(real_numbers)/sizeof(float));
It works everywhere, but: Bummer: Oops! It looks like Task 2 is no longer passing.
4 Answers
simondumalski
3,875 PointsYou changed your coding from task 2. You put:
("Array real_numbers can store %ld items", sizeof(real_numbers)/sizeof(float))
When you should have left the task 2 printf statement how it was. Try putting the task 2 printf statement back and creating a new printf statement with the code you had.
Igor Kletsov
7,556 PointsThank you. Everything works now!
Igor Kletsov
7,556 PointsThanks to all.
I have not noticed: Important: The code you write in each task should be added to the code written in the previous task.
Tolga Beser
1,202 PointsStep 3 requires both step 2 and step 3 printf statements. The wording is very confusing.
Amit Bijlani
Treehouse Guest TeacherThe task is asking you to print the size of the array in bytes and not the length of the array. When you divide it by sizeof(float) you get the number of items but that's not what the challenge is asking for.
Igor Kletsov
7,556 PointsPlease read carefully : Challenge task 3 of 3 --> "Print the length of the array real_numbers using the sizeof() function. Your output should look like the following: Array real_numbers can store x items."
Amit Bijlani
Treehouse Guest TeacherAmit Bijlani
Treehouse Guest TeacherYou need to add to the task so don't delete the
printf
statement from the second task.