Print Even and Odd Number in separate row/colum in one time - [C++ Solution]
1 minute read
Problem Explaination
Suppose you are a book writter. You have to print even and odd number from 1 to 'n' in separate row/colum, as fast as possible.
Problem Solution
#include <iostream>
using namespace std;
int main()
{
int num, a;
num=1;
cout << "Enter how far you want to go : ";
cin >> a;
cout << "Odd numbers " << "Even Numbers" << endl;
while(num <= a){
if(num % 2 == 0)
{
cout <<" "<< num <<" is Even"<< endl;
}
else
{
cout << endl << num <<" is Odd" << endl;
}
num = num + 1;
}
return 0;
}
Post a Comment