A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2FOperators_statements%2Ffor_loop</id>
		<title>C++ Tutorial/Operators statements/for loop - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2B%2B_Tutorial%2FOperators_statements%2Ffor_loop"/>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/Operators_statements/for_loop&amp;action=history"/>
		<updated>2026-04-04T09:50:52Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/Operators_statements/for_loop&amp;diff=2679&amp;oldid=prev</id>
		<title> в 14:21, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/Operators_statements/for_loop&amp;diff=2679&amp;oldid=prev"/>
				<updated>2010-05-25T14:21:17Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:21, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://cppe.ru/index.php?title=C%2B%2B_Tutorial/Operators_statements/for_loop&amp;diff=2680&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://cppe.ru/index.php?title=C%2B%2B_Tutorial/Operators_statements/for_loop&amp;diff=2680&amp;oldid=prev"/>
				<updated>2010-05-25T10:30:15Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==A conversion table of feet to meters==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;  &lt;br /&gt;
using namespace std;  &lt;br /&gt;
  &lt;br /&gt;
int main() {   &lt;br /&gt;
  double f; // holds the length in feet  &lt;br /&gt;
  double m; // holds the conversion to meters  &lt;br /&gt;
  int counter; &lt;br /&gt;
 &lt;br /&gt;
  counter = 0; &lt;br /&gt;
 &lt;br /&gt;
  for(f = 1.0; f &amp;lt;= 100.0; f++) { &lt;br /&gt;
    m = f / 3.28; // convert to meters &lt;br /&gt;
    cout &amp;lt;&amp;lt; f &amp;lt;&amp;lt; &amp;quot; feet is &amp;quot; &amp;lt;&amp;lt; m &amp;lt;&amp;lt; &amp;quot; meters.\n&amp;quot;;  &lt;br /&gt;
     &lt;br /&gt;
    counter++;  &lt;br /&gt;
 &lt;br /&gt;
    // every 10th line, print a blank line &lt;br /&gt;
    if(counter == 10) { &lt;br /&gt;
      cout &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;; // output a blank line &lt;br /&gt;
      counter = 0; // reset the line counter &lt;br /&gt;
    } &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  return 0; &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;1 feet is 0.304878 meters.&lt;br /&gt;
2 feet is 0.609756 meters.&lt;br /&gt;
3 feet is 0.914634 meters.&lt;br /&gt;
4 feet is 1.21951 meters.&lt;br /&gt;
5 feet is 1.52439 meters.&lt;br /&gt;
6 feet is 1.82927 meters.&lt;br /&gt;
7 feet is 2.13415 meters.&lt;br /&gt;
8 feet is 2.43902 meters.&lt;br /&gt;
9 feet is 2.7439 meters.&lt;br /&gt;
10 feet is 3.04878 meters.&lt;br /&gt;
11 feet is 3.35366 meters.&lt;br /&gt;
12 feet is 3.65854 meters.&lt;br /&gt;
13 feet is 3.96341 meters.&lt;br /&gt;
14 feet is 4.26829 meters.&lt;br /&gt;
15 feet is 4.57317 meters.&lt;br /&gt;
16 feet is 4.87805 meters.&lt;br /&gt;
17 feet is 5.18293 meters.&lt;br /&gt;
18 feet is 5.4878 meters.&lt;br /&gt;
19 feet is 5.79268 meters.&lt;br /&gt;
20 feet is 6.09756 meters.&lt;br /&gt;
21 feet is 6.40244 meters.&lt;br /&gt;
22 feet is 6.70732 meters.&lt;br /&gt;
23 feet is 7.0122 meters.&lt;br /&gt;
24 feet is 7.31707 meters.&lt;br /&gt;
25 feet is 7.62195 meters.&lt;br /&gt;
26 feet is 7.92683 meters.&lt;br /&gt;
27 feet is 8.23171 meters.&lt;br /&gt;
28 feet is 8.53659 meters.&lt;br /&gt;
29 feet is 8.84146 meters.&lt;br /&gt;
30 feet is 9.14634 meters.&lt;br /&gt;
31 feet is 9.45122 meters.&lt;br /&gt;
32 feet is 9.7561 meters.&lt;br /&gt;
33 feet is 10.061 meters.&lt;br /&gt;
34 feet is 10.3659 meters.&lt;br /&gt;
35 feet is 10.6707 meters.&lt;br /&gt;
36 feet is 10.9756 meters.&lt;br /&gt;
37 feet is 11.2805 meters.&lt;br /&gt;
38 feet is 11.5854 meters.&lt;br /&gt;
39 feet is 11.8902 meters.&lt;br /&gt;
40 feet is 12.1951 meters.&lt;br /&gt;
41 feet is 12.5 meters.&lt;br /&gt;
42 feet is 12.8049 meters.&lt;br /&gt;
43 feet is 13.1098 meters.&lt;br /&gt;
44 feet is 13.4146 meters.&lt;br /&gt;
45 feet is 13.7195 meters.&lt;br /&gt;
46 feet is 14.0244 meters.&lt;br /&gt;
47 feet is 14.3293 meters.&lt;br /&gt;
48 feet is 14.6341 meters.&lt;br /&gt;
49 feet is 14.939 meters.&lt;br /&gt;
50 feet is 15.2439 meters.&lt;br /&gt;
51 feet is 15.5488 meters.&lt;br /&gt;
52 feet is 15.8537 meters.&lt;br /&gt;
53 feet is 16.1585 meters.&lt;br /&gt;
54 feet is 16.4634 meters.&lt;br /&gt;
55 feet is 16.7683 meters.&lt;br /&gt;
56 feet is 17.0732 meters.&lt;br /&gt;
57 feet is 17.378 meters.&lt;br /&gt;
58 feet is 17.6829 meters.&lt;br /&gt;
59 feet is 17.9878 meters.&lt;br /&gt;
60 feet is 18.2927 meters.&lt;br /&gt;
61 feet is 18.5976 meters.&lt;br /&gt;
62 feet is 18.9024 meters.&lt;br /&gt;
63 feet is 19.2073 meters.&lt;br /&gt;
64 feet is 19.5122 meters.&lt;br /&gt;
65 feet is 19.8171 meters.&lt;br /&gt;
66 feet is 20.122 meters.&lt;br /&gt;
67 feet is 20.4268 meters.&lt;br /&gt;
68 feet is 20.7317 meters.&lt;br /&gt;
69 feet is 21.0366 meters.&lt;br /&gt;
70 feet is 21.3415 meters.&lt;br /&gt;
71 feet is 21.6463 meters.&lt;br /&gt;
72 feet is 21.9512 meters.&lt;br /&gt;
73 feet is 22.2561 meters.&lt;br /&gt;
74 feet is 22.561 meters.&lt;br /&gt;
75 feet is 22.8659 meters.&lt;br /&gt;
76 feet is 23.1707 meters.&lt;br /&gt;
77 feet is 23.4756 meters.&lt;br /&gt;
78 feet is 23.7805 meters.&lt;br /&gt;
79 feet is 24.0854 meters.&lt;br /&gt;
80 feet is 24.3902 meters.&lt;br /&gt;
81 feet is 24.6951 meters.&lt;br /&gt;
82 feet is 25 meters.&lt;br /&gt;
83 feet is 25.3049 meters.&lt;br /&gt;
84 feet is 25.6098 meters.&lt;br /&gt;
85 feet is 25.9146 meters.&lt;br /&gt;
86 feet is 26.2195 meters.&lt;br /&gt;
87 feet is 26.5244 meters.&lt;br /&gt;
88 feet is 26.8293 meters.&lt;br /&gt;
89 feet is 27.1341 meters.&lt;br /&gt;
90 feet is 27.439 meters.&lt;br /&gt;
91 feet is 27.7439 meters.&lt;br /&gt;
92 feet is 28.0488 meters.&lt;br /&gt;
93 feet is 28.3537 meters.&lt;br /&gt;
94 feet is 28.6585 meters.&lt;br /&gt;
95 feet is 28.9634 meters.&lt;br /&gt;
96 feet is 29.2683 meters.&lt;br /&gt;
97 feet is 29.5732 meters.&lt;br /&gt;
98 feet is 29.878 meters.&lt;br /&gt;
99 feet is 30.1829 meters.&lt;br /&gt;
100 feet is 30.4878 meters.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A for loop with no increment==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt; &lt;br /&gt;
using namespace std; &lt;br /&gt;
 &lt;br /&gt;
int main() &lt;br /&gt;
{ &lt;br /&gt;
  int x; &lt;br /&gt;
 &lt;br /&gt;
  for(x=0; x != 123; ) { &lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;Enter a number: &amp;quot;; &lt;br /&gt;
    cin &amp;gt;&amp;gt; x; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  return 0; &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Enter a number: 2&lt;br /&gt;
Enter a number: 3&lt;br /&gt;
Enter a number: 2&lt;br /&gt;
Enter a number: 123&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==A negatively running for loop==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt; &lt;br /&gt;
using namespace std; &lt;br /&gt;
 &lt;br /&gt;
int main() &lt;br /&gt;
{ &lt;br /&gt;
  int i; &lt;br /&gt;
 &lt;br /&gt;
  for(i=50; i &amp;gt;= -50; i = i-10) &lt;br /&gt;
     cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot; &amp;quot;; &lt;br /&gt;
 &lt;br /&gt;
  return 0; &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;50 40 30 20 10 0 -10 -20 -30 -40 -50 &amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Compound interest calculations with for==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
using std::fixed;&lt;br /&gt;
#include &amp;lt;iomanip&amp;gt;&lt;br /&gt;
using std::setw;&lt;br /&gt;
using std::setprecision;&lt;br /&gt;
#include &amp;lt;cmath&amp;gt;&lt;br /&gt;
using std::pow; &lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
   double amount;&lt;br /&gt;
   double principal = 1000.0;&lt;br /&gt;
   double rate = .05; &lt;br /&gt;
   cout &amp;lt;&amp;lt; &amp;quot;Year&amp;quot; &amp;lt;&amp;lt; setw( 21 ) &amp;lt;&amp;lt; &amp;quot;Amount on deposit&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
   cout &amp;lt;&amp;lt; fixed &amp;lt;&amp;lt; setprecision( 2 );&lt;br /&gt;
   for ( int year = 1; year &amp;lt;= 10; year++ ) &lt;br /&gt;
   {&lt;br /&gt;
      amount = principal * pow( 1.0 + rate, year );&lt;br /&gt;
      cout &amp;lt;&amp;lt; setw( 4 ) &amp;lt;&amp;lt; year &amp;lt;&amp;lt; setw( 21 ) &amp;lt;&amp;lt; amount &amp;lt;&amp;lt; endl;&lt;br /&gt;
   }&lt;br /&gt;
   return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Year    Amount on deposit&lt;br /&gt;
   1              1050.00&lt;br /&gt;
   2              1102.50&lt;br /&gt;
   3              1157.63&lt;br /&gt;
   4              1215.51&lt;br /&gt;
   5              1276.28&lt;br /&gt;
   6              1340.10&lt;br /&gt;
   7              1407.10&lt;br /&gt;
   8              1477.46&lt;br /&gt;
   9              1551.33&lt;br /&gt;
  10              1628.89&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Declare loop control variable inside the for==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt; &lt;br /&gt;
using namespace std; &lt;br /&gt;
  &lt;br /&gt;
int main() { &lt;br /&gt;
  int sum = 0; &lt;br /&gt;
  int fact = 1; &lt;br /&gt;
 &lt;br /&gt;
  for(int i = 1; i &amp;lt;= 5; i++) {  &lt;br /&gt;
    sum += i;  // i is known throughout the loop &lt;br /&gt;
    fact *= i; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  // but, i is not known here. &lt;br /&gt;
 &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Sum is &amp;quot; &amp;lt;&amp;lt; sum &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;; &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Factorial is &amp;quot; &amp;lt;&amp;lt; fact; &lt;br /&gt;
 &lt;br /&gt;
  return 0; &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Sum is 15&lt;br /&gt;
Factorial is 120&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Display the alphabet: use char to control for loop==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt; &lt;br /&gt;
using namespace std; &lt;br /&gt;
 &lt;br /&gt;
int main() &lt;br /&gt;
{ &lt;br /&gt;
  char letter; &lt;br /&gt;
 &lt;br /&gt;
  for(letter = &amp;quot;A&amp;quot;; letter &amp;lt;= &amp;quot;Z&amp;quot;; letter++) &lt;br /&gt;
    cout &amp;lt;&amp;lt; letter; &lt;br /&gt;
 &lt;br /&gt;
  return 0; &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;ABCDEFGHIJKLMNOPQRSTUVWXYZ&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==empty for loop statement==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
     int counter=0;      &lt;br /&gt;
     int max = 3;&lt;br /&gt;
     for (;;)   &lt;br /&gt;
     {&lt;br /&gt;
         if (counter &amp;lt; max) &lt;br /&gt;
         {&lt;br /&gt;
             std::cout &amp;lt;&amp;lt; &amp;quot;Hello!\n&amp;quot;;&lt;br /&gt;
             counter++;          // increment&lt;br /&gt;
         }&lt;br /&gt;
         else&lt;br /&gt;
             break;&lt;br /&gt;
     }&lt;br /&gt;
     return 0;&lt;br /&gt;
 }&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Hello!&lt;br /&gt;
Hello!&lt;br /&gt;
Hello!&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Floating point control in a for loop==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;iomanip&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::endl;&lt;br /&gt;
int main() {&lt;br /&gt;
  const double pi = 3.14;&lt;br /&gt;
  cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
  for(double radius = .2 ; radius &amp;lt;= 3.0 ; radius += .2)&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;radius = &amp;quot; &amp;lt;&amp;lt; std::setw(6) &amp;lt;&amp;lt; radius&lt;br /&gt;
         &amp;lt;&amp;lt; &amp;quot;  area = &amp;quot; &amp;lt;&amp;lt; std::setw(12) &amp;lt;&amp;lt; pi * radius * radius&lt;br /&gt;
         &amp;lt;&amp;lt; endl;&lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;radius =    0.2  area =       0.1256&lt;br /&gt;
radius =    0.4  area =       0.5024&lt;br /&gt;
radius =    0.6  area =       1.1304&lt;br /&gt;
radius =    0.8  area =       2.0096&lt;br /&gt;
radius =      1  area =         3.14&lt;br /&gt;
radius =    1.2  area =       4.5216&lt;br /&gt;
radius =    1.4  area =       6.1544&lt;br /&gt;
radius =    1.6  area =       8.0384&lt;br /&gt;
radius =    1.8  area =      10.1736&lt;br /&gt;
radius =      2  area =        12.56&lt;br /&gt;
radius =    2.2  area =      15.1976&lt;br /&gt;
radius =    2.4  area =      18.0864&lt;br /&gt;
radius =    2.6  area =      21.2264&lt;br /&gt;
radius =    2.8  area =      24.6176&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==For loops with null statements==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
     int counter = 0;&lt;br /&gt;
 &lt;br /&gt;
     for( ; counter &amp;lt; 5; )&lt;br /&gt;
     {&lt;br /&gt;
         counter++;&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;Looping!  &amp;quot;;&lt;br /&gt;
     }&lt;br /&gt;
 &lt;br /&gt;
     std::cout &amp;lt;&amp;lt; &amp;quot;\nCounter: &amp;quot; &amp;lt;&amp;lt; counter &amp;lt;&amp;lt; &amp;quot;.\n&amp;quot;;&lt;br /&gt;
     return 0;&lt;br /&gt;
 }&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Looping!  Looping!  Looping!  Looping!  Looping!&lt;br /&gt;
Counter: 5.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Generating multiplication tables==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
#include &amp;lt;iomanip&amp;gt;&lt;br /&gt;
#include &amp;lt;cctype&amp;gt;&lt;br /&gt;
using std::cout;&lt;br /&gt;
using std::cin;&lt;br /&gt;
using std::endl;&lt;br /&gt;
using std::setw;&lt;br /&gt;
int main() {&lt;br /&gt;
  int table = 11;&lt;br /&gt;
  const int table_min = 2;                      &lt;br /&gt;
  const int table_max = 12;                     &lt;br /&gt;
  // Create the top line of the table&lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;     |&amp;quot;;&lt;br /&gt;
  for(int i = 1 ; i &amp;lt;= table ; i++)&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; setw(3) &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot; |&amp;quot;;&lt;br /&gt;
  cout &amp;lt;&amp;lt; endl; &lt;br /&gt;
  &lt;br /&gt;
  // Create the separator row&lt;br /&gt;
  for(int i = 0 ; i &amp;lt;= table ; i++)&lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;------&amp;quot;;&lt;br /&gt;
  cout &amp;lt;&amp;lt; endl;&lt;br /&gt;
  &lt;br /&gt;
  for(int i = 1 ; i &amp;lt;= table ; i++) {   &lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; setw(3) &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot; |&amp;quot;;&lt;br /&gt;
  &lt;br /&gt;
    // Output the values in a row&lt;br /&gt;
    for(int j = 1 ; j &amp;lt;= table ; j++)&lt;br /&gt;
      cout &amp;lt;&amp;lt; &amp;quot; &amp;quot; &amp;lt;&amp;lt; setw(3) &amp;lt;&amp;lt; i*j &amp;lt;&amp;lt; &amp;quot; |&amp;quot;; &lt;br /&gt;
    cout &amp;lt;&amp;lt; endl;                     &lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
  &lt;br /&gt;
  return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;|   1 |   2 |   3 |   4 |   5 |   6 |   7 |   8 |   9 |  10 |  11 |&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
   1 |   1 |   2 |   3 |   4 |   5 |   6 |   7 |   8 |   9 |  10 |  11 |&lt;br /&gt;
   2 |   2 |   4 |   6 |   8 |  10 |  12 |  14 |  16 |  18 |  20 |  22 |&lt;br /&gt;
   3 |   3 |   6 |   9 |  12 |  15 |  18 |  21 |  24 |  27 |  30 |  33 |&lt;br /&gt;
   4 |   4 |   8 |  12 |  16 |  20 |  24 |  28 |  32 |  36 |  40 |  44 |&lt;br /&gt;
   5 |   5 |  10 |  15 |  20 |  25 |  30 |  35 |  40 |  45 |  50 |  55 |&lt;br /&gt;
   6 |   6 |  12 |  18 |  24 |  30 |  36 |  42 |  48 |  54 |  60 |  66 |&lt;br /&gt;
   7 |   7 |  14 |  21 |  28 |  35 |  42 |  49 |  56 |  63 |  70 |  77 |&lt;br /&gt;
   8 |   8 |  16 |  24 |  32 |  40 |  48 |  56 |  64 |  72 |  80 |  88 |&lt;br /&gt;
   9 |   9 |  18 |  27 |  36 |  45 |  54 |  63 |  72 |  81 |  90 |  99 |&lt;br /&gt;
  10 |  10 |  20 |  30 |  40 |  50 |  60 |  70 |  80 |  90 | 100 | 110 |&lt;br /&gt;
  11 |  11 |  22 |  33 |  44 |  55 |  66 |  77 |  88 |  99 | 110 | 121 |&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Loop until a random number that is greater than ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;  &lt;br /&gt;
#include &amp;lt;cstdlib&amp;gt;  &lt;br /&gt;
using namespace std;  &lt;br /&gt;
  &lt;br /&gt;
int main()  &lt;br /&gt;
{  &lt;br /&gt;
  int i;  &lt;br /&gt;
  int r; &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
  r = rand(); &lt;br /&gt;
 &lt;br /&gt;
  for(i=0; r &amp;lt;= 20000; i++) &lt;br /&gt;
    r = rand(); &lt;br /&gt;
     &lt;br /&gt;
  &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Number is &amp;quot; &amp;lt;&amp;lt; r &amp;lt;&amp;lt; &lt;br /&gt;
    &amp;quot;. It was generated on try &amp;quot; &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot;.&amp;quot;; &lt;br /&gt;
  &lt;br /&gt;
  return 0;  &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Number is 26500. It was generated on try 3.&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Simplest for loop statement==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt; &lt;br /&gt;
using namespace std; &lt;br /&gt;
 &lt;br /&gt;
int main() &lt;br /&gt;
{ &lt;br /&gt;
  int count; &lt;br /&gt;
 &lt;br /&gt;
  for(count=1; count &amp;lt;= 100; count=count+1)  &lt;br /&gt;
    cout &amp;lt;&amp;lt; count &amp;lt;&amp;lt; &amp;quot; &amp;quot;; &lt;br /&gt;
 &lt;br /&gt;
  return 0; &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30&lt;br /&gt;
 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 5&lt;br /&gt;
7 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83&lt;br /&gt;
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 &amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==The body of a for loop can be empty==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;  &lt;br /&gt;
#include &amp;lt;cstdlib&amp;gt;  &lt;br /&gt;
using namespace std;  &lt;br /&gt;
  &lt;br /&gt;
int main()  &lt;br /&gt;
{  &lt;br /&gt;
  int i;  &lt;br /&gt;
  int sum = 0; &lt;br /&gt;
  &lt;br /&gt;
 &lt;br /&gt;
  // sum the numbers from 1 through 10 &lt;br /&gt;
  for(i=1; i &amp;lt;= 10; sum += i++) ; &lt;br /&gt;
  &lt;br /&gt;
  cout &amp;lt;&amp;lt; &amp;quot;Sum is &amp;quot; &amp;lt;&amp;lt; sum; &lt;br /&gt;
 &lt;br /&gt;
  return 0;  &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Sum is 55&amp;quot;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use multiple statements in for loops==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 int main()&lt;br /&gt;
 {&lt;br /&gt;
     for (int i=0, j=0; i&amp;lt;3; i++, j++)&lt;br /&gt;
         std::cout &amp;lt;&amp;lt; &amp;quot;i: &amp;quot; &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot; j: &amp;quot; &amp;lt;&amp;lt; j &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
     return 0;&lt;br /&gt;
 }&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;i: 0 j: 0&lt;br /&gt;
i: 1 j: 1&lt;br /&gt;
i: 2 j: 2&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use nested for loops to find factors of numbers between 2 and 100==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;lt;iostream&amp;gt; &lt;br /&gt;
using namespace std; &lt;br /&gt;
 &lt;br /&gt;
int main() { &lt;br /&gt;
 &lt;br /&gt;
  for(int i=2; i &amp;lt;= 100; i++) { &lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;Factors of &amp;quot; &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &amp;quot;: &amp;quot;; &lt;br /&gt;
 &lt;br /&gt;
    for(int j = 2; j &amp;lt; i; j++) &lt;br /&gt;
      if((ij) == 0) cout &amp;lt;&amp;lt; j &amp;lt;&amp;lt; &amp;quot; &amp;quot;; &lt;br /&gt;
 &lt;br /&gt;
    cout &amp;lt;&amp;lt; &amp;quot;\n&amp;quot;; &lt;br /&gt;
  } &lt;br /&gt;
 &lt;br /&gt;
  return 0; &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Factors of 2:&lt;br /&gt;
Factors of 3:&lt;br /&gt;
Factors of 4: 2&lt;br /&gt;
Factors of 5:&lt;br /&gt;
Factors of 6: 2 3&lt;br /&gt;
Factors of 7:&lt;br /&gt;
Factors of 8: 2 4&lt;br /&gt;
Factors of 9: 3&lt;br /&gt;
Factors of 10: 2 5&lt;br /&gt;
Factors of 11:&lt;br /&gt;
Factors of 12: 2 3 4 6&lt;br /&gt;
Factors of 13:&lt;br /&gt;
Factors of 14: 2 7&lt;br /&gt;
Factors of 15: 3 5&lt;br /&gt;
Factors of 16: 2 4 8&lt;br /&gt;
Factors of 17:&lt;br /&gt;
Factors of 18: 2 3 6 9&lt;br /&gt;
Factors of 19:&lt;br /&gt;
Factors of 20: 2 4 5 10&lt;br /&gt;
Factors of 21: 3 7&lt;br /&gt;
Factors of 22: 2 11&lt;br /&gt;
Factors of 23:&lt;br /&gt;
Factors of 24: 2 3 4 6 8 12&lt;br /&gt;
Factors of 25: 5&lt;br /&gt;
Factors of 26: 2 13&lt;br /&gt;
Factors of 27: 3 9&lt;br /&gt;
Factors of 28: 2 4 7 14&lt;br /&gt;
Factors of 29:&lt;br /&gt;
Factors of 30: 2 3 5 6 10 15&lt;br /&gt;
Factors of 31:&lt;br /&gt;
Factors of 32: 2 4 8 16&lt;br /&gt;
Factors of 33: 3 11&lt;br /&gt;
Factors of 34: 2 17&lt;br /&gt;
Factors of 35: 5 7&lt;br /&gt;
Factors of 36: 2 3 4 6 9 12 18&lt;br /&gt;
Factors of 37:&lt;br /&gt;
Factors of 38: 2 19&lt;br /&gt;
Factors of 39: 3 13&lt;br /&gt;
Factors of 40: 2 4 5 8 10 20&lt;br /&gt;
Factors of 41:&lt;br /&gt;
Factors of 42: 2 3 6 7 14 21&lt;br /&gt;
Factors of 43:&lt;br /&gt;
Factors of 44: 2 4 11 22&lt;br /&gt;
Factors of 45: 3 5 9 15&lt;br /&gt;
Factors of 46: 2 23&lt;br /&gt;
Factors of 47:&lt;br /&gt;
Factors of 48: 2 3 4 6 8 12 16 24&lt;br /&gt;
Factors of 49: 7&lt;br /&gt;
Factors of 50: 2 5 10 25&lt;br /&gt;
Factors of 51: 3 17&lt;br /&gt;
Factors of 52: 2 4 13 26&lt;br /&gt;
Factors of 53:&lt;br /&gt;
Factors of 54: 2 3 6 9 18 27&lt;br /&gt;
Factors of 55: 5 11&lt;br /&gt;
Factors of 56: 2 4 7 8 14 28&lt;br /&gt;
Factors of 57: 3 19&lt;br /&gt;
Factors of 58: 2 29&lt;br /&gt;
Factors of 59:&lt;br /&gt;
Factors of 60: 2 3 4 5 6 10 12 15 20 30&lt;br /&gt;
Factors of 61:&lt;br /&gt;
Factors of 62: 2 31&lt;br /&gt;
Factors of 63: 3 7 9 21&lt;br /&gt;
Factors of 64: 2 4 8 16 32&lt;br /&gt;
Factors of 65: 5 13&lt;br /&gt;
Factors of 66: 2 3 6 11 22 33&lt;br /&gt;
Factors of 67:&lt;br /&gt;
Factors of 68: 2 4 17 34&lt;br /&gt;
Factors of 69: 3 23&lt;br /&gt;
Factors of 70: 2 5 7 10 14 35&lt;br /&gt;
Factors of 71:&lt;br /&gt;
Factors of 72: 2 3 4 6 8 9 12 18 24 36&lt;br /&gt;
Factors of 73:&lt;br /&gt;
Factors of 74: 2 37&lt;br /&gt;
Factors of 75: 3 5 15 25&lt;br /&gt;
Factors of 76: 2 4 19 38&lt;br /&gt;
Factors of 77: 7 11&lt;br /&gt;
Factors of 78: 2 3 6 13 26 39&lt;br /&gt;
Factors of 79:&lt;br /&gt;
Factors of 80: 2 4 5 8 10 16 20 40&lt;br /&gt;
Factors of 81: 3 9 27&lt;br /&gt;
Factors of 82: 2 41&lt;br /&gt;
Factors of 83:&lt;br /&gt;
Factors of 84: 2 3 4 6 7 12 14 21 28 42&lt;br /&gt;
Factors of 85: 5 17&lt;br /&gt;
Factors of 86: 2 43&lt;br /&gt;
Factors of 87: 3 29&lt;br /&gt;
Factors of 88: 2 4 8 11 22 44&lt;br /&gt;
Factors of 89:&lt;br /&gt;
Factors of 90: 2 3 5 6 9 10 15 18 30 45&lt;br /&gt;
Factors of 91: 7 13&lt;br /&gt;
Factors of 92: 2 4 23 46&lt;br /&gt;
Factors of 93: 3 31&lt;br /&gt;
Factors of 94: 2 47&lt;br /&gt;
Factors of 95: 5 19&lt;br /&gt;
Factors of 96: 2 3 4 6 8 12 16 24 32 48&lt;br /&gt;
Factors of 97:&lt;br /&gt;
Factors of 98: 2 7 14 49&lt;br /&gt;
Factors of 99: 3 9 11 33&lt;br /&gt;
Factors of 100: 2 4 5 10 20 25 50&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>