? What is the output for y; | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 6

? What is the output for y;

int y = 0} for (int i = 0; i <10; ++ i) y + = i {System.out.println;

16th Jan 2021, 8:40 AM
رزان نعيم
رزان نعيم - avatar
2 Answers
+ 3
1)The syntax for the language seems to be broken please have a look into the course. https://www.sololearn.com/Course/Java/?ref=app 2) You can try it by yourself by going through the codeplay section. Answer is 45 but please try it yourself
16th Jan 2021, 8:47 AM
Aditya
Aditya - avatar
+ 2
This code is not valid, but you probably mean something like this, right? int y = 0; for (int i = 0; i < 10; ++i) y += i; System.out.println(y); Then, the value of y is: y = 0 + 1 + 2 + 3 + ... + 9 = 45
16th Jan 2021, 8:51 AM
Lukáš Vladař