User Tools

Site Tools


cplusplus:repetition_examples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
cplusplus:repetition_examples [2019/02/12 02:19] mithatcplusplus:repetition_examples [2019/02/14 21:28] (current) – [Running total] mithat
Line 34: Line 34:
     cout << num << endl;     cout << num << endl;
     num++;     num++;
-    cout << num << endl; 
  
     return 0;     return 0;
Line 51: Line 50:
 { {
     const int UPPER_LIMIT = 5;     const int UPPER_LIMIT = 5;
-    int num = 1;+    int num = 1;                 // initialize the counter
  
-    while (num <= UPPER_LIMIT)+    while (num <= UPPER_LIMIT)   // test the count
     {     {
         cout << num << endl;         cout << num << endl;
-        num++;+        num++;                   // increment the counter
     }     }
  
Line 144: Line 143:
     while (num <= UPPER_BOUND)     while (num <= UPPER_BOUND)
     {     {
-        sum += num;         // add the new value to the sum+        sum += num;         // add the new value to the accumulator
         num++;         num++;
     }     }
cplusplus/repetition_examples.1549937997.txt.gz · Last modified: 2019/02/12 02:19 by mithat

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki