lab08hw-for-soln - 50 { cout << j...

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

View Full Document Right Arrow Icon
// Solution to http://php.scripts.psu.edu/djh300/cmpsc201/lab08hw-for.htm #include <iostream> using namespace std; int main() { cout << "Countdown from 20 to 1:\n"; for(int i = 20; i >= 1; i--) // print out counting down from 20 to 1 { cout << i << '\t'; } cout << endl; // separate outputs cout << "Even numbers from 20 to 50, 2 ways:\n"; for(int j = 20; j <= 50; j=j+2) // print out evens from 20 to
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 50 { cout &lt;&lt; j &lt;&lt; '\t'; } cout &lt;&lt; endl; // separate outputs for(int j = 20; j &lt;= 50; j++ ) // print out evens from 20 to 50 { // alternate approach if(j%2 == 0) // test for even numbers only { cout &lt;&lt; j &lt;&lt; '\t'; } } cout &lt;&lt; endl; // separate outputs cout &lt;&lt; &quot;The alphabet:\n&quot;; for(char k = 'A'; k &lt;= 'Z'; k++) // print out some alphabet { cout &lt;&lt; k &lt;&lt; '\t'; } return 0; }...
View Full Document

Ask a homework question - tutors are online