csi201_midterm_F08-explained

csi201_midterm_F08-explained - CSI201 Midterm Answers Write...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSI201 Midterm Answers Write a while loop that will print out the values from 0 to 100, inclusive int index = 0 ; while (index <= 100) { System.out.println(index); index = index + 1; } Initialize an index variable to zero Write a while loop that will print out the values from 0 to 100, inclusive int index = 0; while ( index <= 100 ) { System.out.println(index); index = index + 1; } Test that the variable is not yet > 100 Write a while loop that will print out the values from 0 to 100, inclusive int index = 0; while (index <= 100) { System.out.println(index) ; index = index + 1; } Print the current value of the variable (within the loop!) Write a while loop that will print out the values from 0 to 100, inclusive int index = 0; while (index <= 100) { System.out.println(index); index = index + 1; } Increment the variable Write a while loop that will print out the values from 0 to 100, inclusive int index = 0; while (index <= 100) { System.out.println(index); index = index + 1; } I don't care what the name of the variable is. Can test <= 100 or < 101 The output must be inside the loop. rewrite it as a for loop that will do the same thing for ( int index = 0 ; index <= 100; index = index + 1) { System.out.println(index); } Initialize an index variable to zero rewrite it as a for loop that will do the same thing for (int index = 0; index <= 100 ; index = index + 1) { System.out.println(index); } Test that is isn't > 100 rewrite it as a for loop that will do the same thing for (int index = 0; index <= 100; index = index + 1 ) { System.out.println(index); } Increment the index variable rewrite it as a for loop that will do the same thing for (int index = 0; index <= 100; index = index + 1) { System.out.println(index) ; } Print the current value of the variable (within the loop!) Write a loop (either while or for) to insert into this code that...
View Full Document

This note was uploaded on 01/17/2009 for the course CSI 201 taught by Professor Doanne during the Fall '08 term at SUNY Albany.

Page1 / 34

csi201_midterm_F08-explained - CSI201 Midterm Answers Write...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online