- To print Even numbers between 1 to N

User Input: 9

Output: 2 4 6 8

```
#include <iostream>
using namespace std;
int main() {
int num;
cout<<"Enter your last number: ";
cin>>num;
cout<<"Your even numbers are : ";
for (int i=1; i<num; i++)
if(i%2==0) cout<<i<<" ";
return 0;
}
```

Enter your last number : 7 Your even numbers are : 2 4 6Program

basic

You should know first :

**Even numbers: ** Numbers perfectly divisible by 2

`(number % 2 == 0)`

So, we are using a for loop till the last number entered and check every value for even

```
for(int i=0; i<LastValue; i++) {
//Check every 'i' for even, if even then print
}
```

Concept
Coming Soon !

QuickTutorial

In order to succeed you must fail, so that you know what not to do the next time.