demo-while - i++; // update step } cout...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// Demo of simple while loops, designed to mirror the simple for loops demo program // Notice how the basic building blocks of the loop move around #include <iostream.h> int main() { int i = 1; // LCV -- initial condition while(i <=5) // print out counting from 1 to 5 { // (loop test inside the while) cout << i << '\t'; // <--- loop body
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: i++; // update step } cout &lt;&lt; endl; // separate outputs int j = 1890; // LCV while(j &lt; 2020) // print out every 10th year from 1890-2010 { cout &lt;&lt; j &lt;&lt; '\t'; j=j+10; } cout &lt;&lt; endl; // separate outputs char k = 'D'; // LCV while(k &lt; 'J') // print out some letters { cout &lt;&lt; k &lt;&lt; '\t'; k++; } return 0; }...
View Full Document

Ask a homework question - tutors are online