I just started to study C++, and I want to ask why my simple code's output is not right.
What I want:
user input N -> output = " N number that mod 2 =0 but not mod 3=0"
What I got:
user input N -> output = " number that mod 2 but not mod3=0 , with range until n "
Here is my code:
#include <iostream>
#include <conio.h>
int main()
{
int i,n;
std::cout << "input n" << std::endl;
std::cin >> n;
std::cout << "N Number that mod2=0 but mod3!=0" << std::endl;
for ( i = 1; i <= n; ++i )
{
if ( i % 2 == 0 && i % 3 != 0 )
{
std::cout << i < " ";
}
}
getch ();
}