3 votes 3 votes Consider the following code segment: for (int k=0; k<20; k=k+2) { if (k % 3 == 1) system.out.print(k+ " "); } What is printed as a result of executing the code segment? 4 16 4 10 16 0 6 12 18 1 4 7 10 13 16 19 Object Oriented Programming isro2008 java + – go_editor asked Jun 12, 2016 • recategorized Dec 9, 2022 by Lakshman Bhaiya go_editor 3.7k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 6 votes 6 votes Option B 4 10 16 k =0 % 3 =0 since k is incremented by 2 = 2%3=2 =4%3=1 -----------------prints 4 = 6%3 =0 = 8%3=2 =10%3=1 ------------- prints 10 =12%3 =0 ......... Therefore Output is 4 10 16 shivanisrivarshini answered Jun 12, 2016 • selected Jun 14, 2016 by LeenSharma shivanisrivarshini comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes Answer will be B) Here the value printed when ((k%3)==1) And 4,10,16 gives those value between 1 to 20 srestha answered Jun 12, 2016 srestha comment Share Follow See all 0 reply Please log in or register to add a comment.