# Two memory locations M1 and M2, contain 32 bit values.

Two memory locations M1 and M2, contain 32 bit values.
Write a program to compare the 3 bit values ( bit19,bit18,bit17)of M1
with 3 bit values ( bit9,bit8,bit7) of M2 and print EQUAL if they are equal

• : Two memory locations M1 and M2, contain 32 bit values.
: Write a program to compare the 3 bit values ( bit19,bit18,bit17)of M1
: with 3 bit values ( bit9,bit8,bit7) of M2 and print EQUAL if they
: are equal
:
It's a bit of a bad question, because a program cannot compare two memory locations, unless it has access to core memory it doesn't own.

I suspect the teacher means "input two 32 it numbers".

long is guaranteed to be at least 32 bits. So you can use scanf("%ld" ...) to input the numbers.
Then use the and (&) and shift (>>) operators to manipulate your bits, and printf() to output the result.

• This seems rather simple on a 32 bit machine and compiler:

Use unsigned int and grab the two values

Create two masks to isolate the important bits

Use bitwise and & to modify the two values

Use bitwise shift << or >> to move one or the other value 10 bits
(Or, you could simply multiply or divide by the appropriate value)

Use simple if() to compare the new values

It should only take about seven actual lines of code.

Take Care,
Ed
• : It's a bit of a bad question, because a program cannot compare two
: memory locations, unless it has access to core memory it doesn't own.

Nobody said "Windows"! :-)