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;
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
+ 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