Thursday, September 25, 2014

WAP in C++ to show an input number is even or odd without the use of modulus operator.

#include
#include
void main()
{
            int n,i,d=0;
   cout<<"enter a number: "<
   cin>>n;
   d=n;
   for(i=0;i
   {
            d=d-2;
      }
   if(d==0)
            cout<<"No. is even";
   else
            cout<<"No. is odd";
   getch();

}

No comments:

Post a Comment