Need help for homework assignment!

Jimmy93

Junior Member
May 4, 2012
1
0
0
I am using C and I am a beginner.
I have to write a function that manipulates bits.
Write a main program to test the function.
Experiment with Sleep and Beep functions to play music.

Write a function with the following function prototype that rotates the bits in a int by one bit tot the left each time and returns the rotated value to the caller/

Write a main program to display the binary data each time it is rotated and generate a console output. Use Sleep() to delay the printing of each bit and Beep() to make a sound each time a bit is printed.

So basically i have to scan in a number from the keyboard, change it into binary, then have the 1 move to the left. Each time the 1 moves a tune has to come on.

this is what our teacher gave us just as a starter

void DisplayBits(int iValue)
{
int iBitCount; //bit counter
int iMask = 1 << 31; //bit mask

printf("%11d = ", iValue);

for(iBitCount = 1; iBitCount <= 32; iBitCount++)
{
if(iValue & iMask)
putchar('1'); //endif
else
putchar('0'); //endelse

iValue <<= 1; //shift value 1 bit to left

if(iBitCount % 8 == 0)
putchar(' '); //endif
} //endfor

putchar('\n');
} //endDisplayBits

Thank you very much
 

aceO07

Diamond Member
Nov 6, 2000
4,491
0
76
What exactly are you looking for help on?

Nobody is going to do your homework for you, but if you had a specific question someone may be able to help.
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
What have you done to analyze the problem and attack it?

As stated above, homework help is not provided here.