i have to write a c code that it divides a number by a power of 2 by shifting
the number to the right the requisite number of bits.

im not asking for ANY CODE. im just asking for an explanation for the given.

how do we divide by shifting to the right ? can you please give me an example with an explanation?

thanks

>>how do we divide by shifting to the right
use the >> shift operator x >>= 2; will shift the value of x right 2 and store the result back in x

Oh alright. thank you :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.