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
using namespace std;
class test1 {
public:
int n;
void printeven(int n) {
int i =0;
while ( i< n) {
if(i%2==0){
cout< }
i++;
}
}
};
int main() {
test1 o ;
cout<<“Enter a Number till want list:”<
cout<<“All Even Number list”<
}
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
using namespace std;
class test1 {
public:
int n;
void printeven(int n) {
int i =0;
while ( i< n) {
if(i%2==1){
cout< }
i++;
}
}
};
int main() {
test1 o ;
cout<<“Enter a Number till want list:”<
cout<<“All Even Number list”<
}
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.
If any doubt about this c++ programming code or input & output please comment below
If you have another question about c++ programming send an email by contacting us form is given on the page right side.
I am Try to Help in your Programming Language by Programming Shortcut
Please share your experience about this post,
Thank You!