Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

These two functions needs to be written in C language.. please include what main

ID: 3641251 • Letter: T

Question

These two functions needs to be written in C language.. please include what main will say, if possible comment it out also.

1) unsigned longest1Run( unsigned n );
The function returns the largest number of consecutive 1-bits in n. For instance, if n’s bits were
11110111 00111111 10110100 00101111
the function would return 7 (because of the 7 underlined 1-bits).

2) unsigned mixItUp( unsigned n );
The number you return should have all bits with prime position set to 1, all bits with square position set
to 0, and all the other bits set to the opposite of the corresponding bits in n. Your function doesn’t have to
compute the prime numbers, it can just know that the prime numbers less than 32 are 2, 3, 5, 7, 11, 13, 17, 19,
23, 29,31. Likewise, your function doesn’t have to compute the perfect squares, it can just know that the perfect
squares less than 32 are 0, 1, 4, 9, 16, 25.
For instance, suppose the bits of n are
00101001 01110101 11011101 01011011
Then the bits that are returned are
11110100 10001010 00101000 10101100
(All the bits with prime position are underlined and equal to 1, all the bits with square position are double-
underlined and equal to 0, and all the rest of the bits are the opposite of the corresponding bits in n.)


Explanation / Answer

please rate - thanks

I don't get part 2-sorry

#include<stdio.h>
#include<conio.h>
unsigned longest1Run( unsigned n );
int main()
{printf("longest run is %d ",longest1Run(0XF73FB42FU));
getch();
return 0;
}
unsigned longest1Run(unsigned a)
{unsigned int mask=0x80000000,b;
int i,count=0,max=0;

for(i=0;i<32;i++)
{b=a&mask;
   if(b==0)
      { if(count>max)
           max=count;
      count=0;
      }
   else
      count++;     
   mask=mask/2;
    }

return max;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote