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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
Fabrizio Rinaldi
5,359 PointsArray_Length
float real_numbers [] = {1.11, 1.12, 1.13, 1.14, 1.15};
printf ("Array real_numbers can store %ld items.", sizeof(real_numbers)÷sizeof(float));
i can't find the mistake in this part of code, anyone can help me?
7 Answers
![Jason Anello](https://secure.gravatar.com/avatar/d1304e75238ff7f216f55adc03e08ea1?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Jason Anello
Courses Plus Student 94,610 PointsHi Fabrizio,
You want to use the forward slash for the division operator /
You've got a division symbol in there instead.
sizeof(real_numbers) / sizeof(float)
![Andrew Pham](https://secure.gravatar.com/avatar/42126902d1def7ec44bc11132099183c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Andrew Pham
3,492 PointsIs it possible that the result of 'sizeof(real_numbers)÷sizeof(float)' returns an integer, hence the string formatting '%ld' (long) is incorrect? Try changing '%ld' to '%d'
Fabrizio Rinaldi
5,359 Pointsok, i'll do that! thank you Andrew ;)
Fabrizio Rinaldi
5,359 PointsTask:
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.
Solution:
float real_numbers [] = {1.1, 1.2, 1.3, 1.4, 1.5};
printf("Array real_numbers can store %ld items.", sizeof(real_numbers) / sizeof(float));
Error:
Make sure you are calling printf and passing a string (not an NSString) and real_numbers
as the parameters. The correct format option is '%ld'.
I can't find the mistake and it continues to say that's equal to the exercise i've done before.
For andrew: is right to write %ld, cuz i've tried with %d and gives me an error.
![Jason Anello](https://secure.gravatar.com/avatar/d1304e75238ff7f216f55adc03e08ea1?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Jason Anello
Courses Plus Student 94,610 PointsDid you recycle the printf statement from task 2 when doing task 3? You should keep previous code in place if that's what happened.
Fabrizio Rinaldi
5,359 PointsI deleted printf("Array real_numbers is %ld bytes.", sizeof(real_numbers)); and shown me that error.
Now i completed the exercise ;)
![Andrew Pham](https://secure.gravatar.com/avatar/42126902d1def7ec44bc11132099183c?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Andrew Pham
3,492 PointsYes agreed with Jason. Your final code should be: float real_numbers[5]; printf("Array real_numbers is %ld bytes.", sizeof(real_numbers)); printf("Array real_numbers can store %ld items.", sizeof(real_numbers) / sizeof(float));