Print First Five Even Numbers using CPP

  1. Home
  2. Tutorials
  3. CPP
  4. CPP Programs
  5. While Loop
  6. Program

Source Code

#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    int i = 1 ;  // i is for counter variable.
    
    // Output Message
    cout<<"First Five Even Numbers:"<<endl;
    // while loop for print first 5 even numbers.
    while ( i <= 10 ) {
        if ( i % 2 == 0 ) {
            cout<<i<<endl;
        }
        i = i + 1;
    }
    return 0;
}

Output

print first 5 even numbers using while loop in c++

Comments
Login to TRACK of Comments.