Print First Five Even Numbers using CPP
- Home
- Tutorials
- CPP
- CPP Programs
- While Loop
- 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;
}