Int y; for(y=1;y<=5;y+=3) cout <<y; почему отсюда выходит output 7? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Int y; for(y=1;y<=5;y+=3) cout <<y; почему отсюда выходит output 7?

help me

28th Aug 2017, 9:02 PM
pro
pro - avatar
4 Answers
+ 2
The output should be 14. y = 1. y <= 5 is true. Output: 1 y += 3 is 4. y <= 5 is true. Output: 4 y += 3 is 7. y <= 5 is false. So, cout doesn't run. I suggest reviewing the for loop in the course. If there are no brackets the first statement in the code is considered inside the loop.
28th Aug 2017, 9:06 PM
Rrestoring faith
Rrestoring faith - avatar
0
l think as you,but this programme gives 7!!!really amazing
29th Aug 2017, 6:41 PM
pro
pro - avatar
0
put this in compiler and you saw the same
29th Aug 2017, 6:43 PM
pro
pro - avatar
0
У Вас, скорее всего, перед cout где то фигурные скобки спрятались.
30th Aug 2017, 9:14 PM
Владимир Шаповал
Владимир Шаповал - avatar