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
128
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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top