Macro

Joined
Jul 8, 2023
Messages
3
Reaction score
0
Write a macro P(X,Y) that returns 1 if X is even and grater then Y.

How would I do that?
 
Joined
Sep 4, 2022
Messages
158
Reaction score
16
Even and Odd numbers can be tested by the 'modulo 2' instructions % 2.

if it return 0, you are on a Even number.
if more than 0, you're in Odd

C++:
function serial number(X,Y){

  if( ( X % 2 == 0 ) &&  (X > Y ){

   return 1;

  {
   return 0 ;
  }
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,260
Messages
2,571,038
Members
48,768
Latest member
first4landlord

Latest Threads

Top