Showing posts with label Loop. Show all posts
Showing posts with label Loop. Show all posts

Sunday, March 22, 2009

Puzzle 8 – Solution

The key here is the local variable ‘i’ is overwritten every time the inner for loop runs.

The Loop iterate in the manner depicted below,

Outer Loop : i = 0
Inner Loop : i = 0 to 5
Outer Loop : i = 6
Inner Loop : i = 0 to 5
Outer Loop : i = 6
and this pattern keeps repeating.

Congrats to
1. Joe Smith
2. Tanzy
for getting the correct answer.

Joe & Tanzy - you can leave a link to your profile/blog or site if you want it to show up in the Top Score Section.

Wednesday, March 18, 2009

Puzzle 8 – Misleading Count.

Language – Java | Type – Concept | Last date 22-Mar-2009 12:00 p.m. IST | Points 2

This is why ‘i’ am so important …

package com.twisters;
public class MyLoop {
public static void main(String[] args) {
for(int i=0;i<10;i++){
for(i=0;i<5;i++){
System.out.println("Testing");
}
}
}
}
Got an answer? Why don’t you leave it here.