write a program that asks for an integer and displays for the user whether the number is even or odd. hint: use if/else and the modulus operator.
Anybody please help me in c++?
http://educ.queensu.ca/~compsci/units/oo...
Reply:Do your own homework.
Reply:#include%26lt;iostream.h%26gt;
main()
{
cout%26lt;%26lt;"enter the number";
cin%26gt;%26gt;a;
if(a%2==0)
{
cout%26lt;%26lt;"number is even";
}
else
{
cout%26lt;%26lt;"number is odd";
}
}
//I hope it will work. Please include necessary header files. I might have missed .But logic is absolutely 100% fine.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment