# Programming Shortcut

## Monday, February 4, 2019

### List of even and odd numbers list 1 to n in c++

Hello friends! Welcome to my website

Today We Run a program to print all even and odd numbers lists in oops concepts in c++.
This session is how to print the even or odd numbers list in c++ Programming. Here we show you, how to use while loop and if loop programming with Example and oops concepts in c++
This c++ language programming is free all type of errors like the compiler and runtime errors and this programming is tested to compile and then run the program code.
Here is only programming code with the output. This programming output is customized to understand easily.

### Print all even numbers between 1 to n in c++

#include <iostream>
#include <cmath>
using namespace std;
class test1 {
public:
int n;
void printeven(int n) {
int i =0;
while ( i< n) {
if(i%2==0){
cout<<i<<", ";
}
i++;
}
}
};
int main() {
test1 o ;
cout<<"Enter a Number till want list:"<<endl;
cin>>o.n;
cout<<"All Even Number list"<<endl;
o.printeven(o.n);
}

Output:    Enter a Number till want list: 20
All Even Number list
0, 2, 4, 6, 8, 10, 12, 14, 16, 18,

### Print all odd numbers between 1 to n in c++

#include <iostream>
#include <cmath>
using namespace std;
class test1 {
public:
int n;
void printeven(int n) {
int i =0;
while ( i< n) {
if(i%2==1){
cout<<i<<", ";
}
i++;
}
}
};
int main() {

test1 o ;
cout<<"Enter a Number till want list:"<<endl;
cin>>o.n;
cout<<"All Even Number list"<<endl;
o.printeven(o.n);
}

Output:    Enter a Number till want list: 20
All Odd Number list
1, 3, 5, 7, 9, 11, 13, 15, 17, 19,

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.