How do u get this?? I dont understand the % part

I dont understand how u get that with the %... What type of statement is this?

1
2
for (int i=1; i<=3; i++)    cout<<i<<14%i;

Answer: 102032
% gives you the remainder after division. 7%3 == 1 because 7/3 has a remainder of 1.

Your code will loop 3 times, each time printing 2 numbers, i, and 14%i:

first iteration (i=1):
- prints i (1)
- prints 14%i ... 14/1 has no remainder (0)

second iteration (i=2):
- prints i (2)
- prints 14%i ... 14/2 has no remainder (0)

third iteration (i=3):
- prints i (3)
- prints 14%i ... 14/3 is 4 remainder 2


All that output crammed together: 102032
Last edited on
I figured it out before u answered, omg was it easy lol. Thank u though. Wow. After I kept looking at it I realized how to do it . Man I love this stuff!!!!
Last edited on
Topic archived. No new replies allowed.