Pages

In listening to a recent Stackoverflow podcast Joel Spolsky was discussing one of his interview questions. How to determine if a point is within a rectangle. This was a great question and I spent the rest of my commute trying to determine how many different languages and ways you can do this.

My favorite has to be using the .Net framework’s Rectangle.Contains(Put Point Here).

This made me think. In any given day most developers, at least I do, program in several languages. Even if you are only flipping back and forth between C# and Vb.Net. This made me think of another basic interview questions. Can you show me four different ways to write a simple FOR loop. Bonus points for different languages.

JavaScript

for (var i =0; i < arr.length; i++) {// some code here}

Or

for (var i =0, len = arr.length; i < len; i++) {// some code here}

C#

for(int i =1;i<=10;i++){//Some code here}

PL/SQL

FOR i IN1..1000 LOOP-- Some code hereEND LOOP;

Java

for (int i =0; i < args.length; i = i +1) { // Test and Loop// Some code here}