Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2. do/while
- 3. count controlled loop
- 4. true
- 11.
- Hello
- Hello
- Hello
- Done
- 12.
- Hello
- Hello
- Hello
- Done
- 13. 2
- 14. 2033
- 15. 10, 5
- 16. 60, 40
- 17. 20 , 10
- 18. 40, 5
- 19.
- 3
- 3
- 3
- 3
- 4
- 27.
- for ( i=0, i<5, i++)
- 29.
- package com.company;
- public class exercises {
- public static void main(String [] args)
- {
- int sum = 0;
- int i;
- for(i=0;i<5;i++)
- {
- sum += i;
- }
- System.out.print(sum);
- }
- }
- 32.
- The print statement is not in the loop.
- It needs {} brackets.
- 33.
- i will always be larger than 10.
- 35.
- It prints i, not the sum.
- 38.
- Bad syntax.
- switch out i<3 and i++
- 39.
- for adds 1 to i before it prints Hello.
- So you need an extra iteration.
- Lower i to 0 or raise its constraint to 4.
- 40.
- for statement needs semicolons.
- 41. i isnt declared as an integer.
- 42. i doesnt need value assignment, just declaration.
Add Comment
Please, Sign In to add comment