# When i compile the exact code in the course it doesnt work as mr mosh code

**URL:** <https://forum.codewithmosh.com/t/when-i-compile-the-exact-code-in-the-course-it-doesnt-work-as-mr-mosh-code/17790>\
**Category:** C++\
**Created:** [January 19, 2023, 12:15pm UTC](https://forum.codewithmosh.com/t/when-i-compile-the-exact-code-in-the-course-it-doesnt-work-as-mr-mosh-code/17790 "2023-01-19T12:15:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shahin1371](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/shahin1371/32/5418_2.png) [@shahin1371](https://forum.codewithmosh.com/u/shahin1371)\
**Post date:** [January 19, 2023, 12:15pm UTC](https://forum.codewithmosh.com/t/when-i-compile-the-exact-code-in-the-course-it-doesnt-work-as-mr-mosh-code/17790/1 "2023-01-19T12:15:28Z")

</div>

in the image you can see my code, it is suppose to cout the numbers in the array, in course 2 section 3 (determining the size of arrays) mr mosh types this exact code and gets the number of arrays and the loop stops, but when i wrote the exact same thing after arrays the loop continues and still prints random numbers so im really confused cause i know i wrote the same exact code but why his loop stops after counting the arrays but mine doesnt

 ![compile error](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/8/83f005bb1dd0d2884e8a8d7e513812d46b571676.png)

and this is the code mr mosh wrote in the course:

#include

using namespace std;

int main(){

```
int numbers[] = {10, 20,30, 40, 50};
 for (int i = 0; 1 < size(numbers); i++)
     cout << numbers[i] << endl;

return 0;

```

}

---

<div class="post-metadata">

**Author:** ![SAM](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sam/32/167_2.png) [@SAM](https://forum.codewithmosh.com/u/SAM)\
**Post date:** [January 19, 2023, 12:51pm UTC](https://forum.codewithmosh.com/t/when-i-compile-the-exact-code-in-the-course-it-doesnt-work-as-mr-mosh-code/17790/2 "2023-01-19T12:51:54Z")

</div>

You made a typo. Your loop condition is `1 < size(numbers)` and since 1 is always smaller than the size of your array your loop will not end.

Replace the `1` in your condition by the loop variable `i` and it will work as expected.
