How to Print Even & Odd numbers in C++
Today we will learn how to print Even Odd numbers in C++ Programming language.
Even Number Print 1 to 100
In this code we will print Even numbers try it in your code and enjoy programming.
#include<iostream>
using namespace std;
int main(){
int n=5;
int x=2;
for(int i=1; i<=n; i++)
{
for(int j=1;j<=n; j++)
{
cout<<x<<" ";
x+=2;
}
cout<<endl;
}
return 0;
}
Output:
Odd Number Print 1 to 50
In this code we will print Odd numbers try it in your code and enjoy programming.
#include<iostream>
using namespace std;
int main()
{
//odd Numbers 1 to 50
int n=5;
int x=1;
for(int i=1; i<=n; i++)
{
for(int j=1;j<=n; j++)
{
cout<<x<<" ";
x+=2;
}
cout<<endl;
}
return 0;
}
Output:
______________________The End____________________
If you have any problem about this lecture or about any other problem then just leave your comment here, I will read and reply here.
Post a Comment