right rotation in turbo c

can anyone help me with the code:

of a function that rotates to the right by n bit positions the bits of an unsigned char...



  • [code]
    unsigned char RotateBits2Right (unsigned char uchValue, int nBits)
    int bRightMostBitIs1;

    nBits %= 8;
    while (nBits--)
    bRightMostBitIs1 = (uchValue & 1);
    uchValue >>= 1;
    if (bRightMostBitIs1) uchValue |= 0x80;
    return uchValue;
  • tnx..
    how will i print it??

  • To print an integer in the C language, use the printf() function.


    Please don't respond to code begging where the original poster has made no effort by themselves. Normally I'd remove threads like this, but I'll leave it alone this time since the damage is already done... one more user who will continue to spam the boards next time he's got a homework assignment.

    And the code itself is a good, basic algorithm that is useful for people searching the boards in the future.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!