if ( i % 12 == 0)
{
cout << "i = " << i << endl;
}
i % 12 means get the remainder of i which is zero divided by 12 is equal to zero?
then i increments by 1 and now it's i is 1? divided by 12?
I'm confused now.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
usingnamespace std;
int main()
{
for (int i = 1; i < 1000; i++)
{
if ( i % 12 == 0)
{
cout << "i = " << i << endl;
}
}
}
Why it starts counting at 12? I initialize variable to 1 but it started as 12?
i = 12
i = 24
i = 36
i = 48
i = 60
i = 72
i = 84
i = 96
i = 108
i = 120
i = 132
i = 144
i = 156
i = 168
i = 180
i = 192
i = 204
i = 216
i = 228
i = 240
i = 252
i = 264
i = 276
i = 288
i = 300
i = 312
i = 324
i = 336
i = 348
i = 360
i = 372
i = 384
i = 396
i = 408
i = 420
i = 432
i = 444
i = 456
i = 468
i = 480
i = 492
i = 504
i = 516
i = 528
i = 540
i = 552
i = 564
i = 576
i = 588
i = 600
i = 612
i = 624
i = 636
i = 648
i = 660
i = 672
i = 684
i = 696
i = 708
i = 720
i = 732
i = 744
i = 756
i = 768
i = 780
i = 792
i = 804
i = 816
i = 828
i = 840
i = 852
i = 864
i = 876
i = 888
i = 900
i = 912
i = 924
i = 936
i = 948
i = 960
i = 972
i = 984
i = 996
Could someone explain this better to me line by line how this program .
I just started to today learning c++ and didn't expected programming is very confusing but it's fun.