Uses only the test expression in the for loop to count by fives. - C++ Statement

C++ examples for Statement:for

Description

Uses only the test expression in the for loop to count by fives.

Demo Code

#include <iostream>
using namespace std;
int main()//from ww  w.  ja  va 2s.  com
{
   int num=5;                            // Starting value
   cout << "\nCounting by 5s: \n";                // Title
   for (; num<=100;)  // Contains only the test expression.
   {
      cout << num << "\n";
      num+=5;    // Increment expression outside the loop.
   }                           // End of the loop's body
   return 0;
}

Result


Related Tutorials