-
C++
I am a beginner learning C++; I having problems with my first program and I need some help. How do I write a program that determines odd, even and mixed sets of number using modulus (%)?
-
modulus is integer division, getting the integer quotient and remainder. Dividing an integer by an even number the remainder will be 0, thus if num%2 == 0 the variable num must be even the rest you should be able to figure out.
-
Its not rocket science
# inlcude <iostream.h>
# include <conio.h>
main()
{
int a,b;
cout<<" Enter a number ";
cin>>a;
b=a%2;
if(b==0)
cout<<" Even number";
else
cout<<" Odd number ";
}
Popular pages
Recent additions