[prog] more C++

wolf wolf at wolfrising.net
Sat Dec 13 16:28:49 EST 2003


Hi,

I'm trying to work on another sample for C++, I was trying to make a 
little program that would say if the number you give it
is odd or even. Sounded like a simple idea : ) It seems to me it should 
you the modulus as opposed to just dividing the
sample number by 2. However so far, nothing I've tried seems to work. 
Am I way off target or have I made an obvious
error?  Thank you : )


#include <iostream>

int main()

{

         int integer1
         int x=even;
         int y=odd


          std::cout << "Enter a number\n";
          std::cin >> integer1;


         if(x % y ){
                         even = integer1;
                 }
                 else {
                         odd = integer1;
                 }
         }


          std::cout << "The number  is " << odd << even << std::endl;

          return 0;

}



More information about the Programming mailing list