C++ Program to display even numbers from 1 to 100


In this Program, You will learn how to display even numbers from 1 to 100 in C++.


if(i % 2 == 0){ }


Example: How to display even numbers from 1 to 100 in C++

Run it Now
#include<iostream>
using namespace std;

int main() {

    int i;

    for (i = 1; i <= 100; i++) {
        if (i % 2 == 0) {
            cout << "Even Number :" << i << endl;
        }
    }

    return 0;
}

Output:

Even Number :2
Even Number :4
Even Number :6
Even Number :8
Even Number :10
Even Number :12
Even Number :14
Even Number :16
Even Number :18
Even Number :20
Even Number :22
Even Number :24
Even Number :26
Even Number :28
Even Number :30
Even Number :32
Even Number :34
Even Number :36
Even Number :38
Even Number :40
Even Number :42
Even Number :44
Even Number :46
Even Number :48
Even Number :50
Even Number :52
Even Number :54
Even Number :56
Even Number :58
Even Number :60
Even Number :62
Even Number :64
Even Number :66
Even Number :68
Even Number :70
Even Number :72
Even Number :74
Even Number :76
Even Number :78
Even Number :80
Even Number :82
Even Number :84
Even Number :86
Even Number :88
Even Number :90
Even Number :92
Even Number :94
Even Number :96
Even Number :98
Even Number :100