Binary representation of each input hex integer Sample input

Binary representation of each input hex integer Sample input: 0 times 4 0 times a015 Sample output: 0100 1010 0000 0001 0101 Write a C function that computes a left circular shift on an unsigned int. It works like a typical left shift, but any value that gets shifted off the left side wraps back around to the right side. Include both a declaration and the function definition. The function declaration should be: unsigned int Icirc-shift (unsigned int num, unsigned int shifts); Some examples:

Solution

unsigned long left_circular_shift( unsigned long data, unsigned int change )
{
unsigned int len = 32;
if ( change >= len ) change %= len;
unsigned long larbts = data << len;
unsigned long smalbts = data >> len -change;
return larbts | smalbts;
}4)#include<stdio.h>
#include<math.h>

int main()
{
   int decmal = 0, rm, hexdecmal;
   int c= 0;
       int cn, kn;
   printf(\"enter hexadecmal no:\");
   scanf(\"%d\", &hexdecmal);  
   while(hexdecmal > 0)
   {
       rm= hexdecmal % 10;
       decmal= decmal + rm * pow(16, c);
       hexdecmal = hexdecmal / 10;
       c++;
   }
//   printf(\"\ decimal value is:\\t%d\ \", decmal);
printf(\"\ \");

for (cn = 31; cn >= 0; cn--)
{
kn = decmal >> cn;

if (kn& 1)
printf(\"1\");
else
printf(\"0\");
}

printf(\"\ \");
   return 0;
}
output:
enter hexadecmal no:13452
00000000000000010011010001010010

 Binary representation of each input hex integer Sample input: 0 times 4 0 times a015 Sample output: 0100 1010 0000 0001 0101 Write a C function that computes a

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site