Directions: Each of these requires you to write a simple driver and at
least one function. The problems below describe the actual function
and NOT the required driver. The required driver is up to the
designer...you.
NOTE: Problems 1 & 2 require a character array which can be declared
as: char StringArray[80];
1.) Write a function called StringWrapper that accepts a pointer to a
character array. The purpose of this function is to "wrap" the string
around itself slowly (use delay() in conio.h) in the same position on
the screen for one full cycle of the string. The function prototype
should be:
void StringWrapper(char *String);
/* PRE: String points to a predefined variable character array.
POST: None.
CALLS: Up to designer........... */
Sample Output: String = This is a test.
At position (1,1) : This is a test. (delay)
At position (1,1) : .This is a test (delay)
At position (1,1) : t.This is a tes (delay)
At position (1,1) : st.This is a te (delay)
At position (1,1) : est.This is a t (delay) and so forth
2.) Write a function called CaseJumbler accepts a pointer to a
character array and returns the stringin an alternating
uppercase/lowercase format. The function prototype should be:
void CaseJumbler (char *String);
/* PRE : String points to a predefined variable character array.
POST : Returns String with alternating cases for each letter in the
string.
CALLS : Up to designer.......... */
Sample Output: String = This is another string test.
ThIs Is AnOtHeR sTrInG tEsT.
..OR..
tHiS iS aNoThEr StRiNg TeSt.
3.) Write a function called DecimalToBinary that accepts an unsigned
integer value and prints to the screen the equivalent value in binary
format after converting the value and storing it in a character array.
The function prototype should be:
void DecimalToBinary (unsigned int Value);
/* PRE : Value contains a positive integer.
POST : Prints to the screen the binary equivalence of Value.
CALLS : Up to designer........ */
Sample Output: Value = 15660
Binary Form: 0011 1101 0010 1100
Value = 287
Binary Form: 0000 0001 0001 1111
CAN ANYONE DO THIS??
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
However, it wouldn't be much of a homework assignment if someone else did it for you. Take a stab at it. Ask for help on particular issues or suggestions on a particular question.
Just dumping an assignment on a message board, though, won't get you very far, especially with the more ethical or more busy of us.
im a sophmore in high school
this semester i made the jump to c
it has been really tough
the teacher wont teach and yells like crazy
it is so hard i read the book every day but itt doesnt help
i seriously am in grave danger of failing
i need to get this done by tomorrow but hae no dea where to start
i understand that u have a life and arent going to go doing kids homework
its impossible
if u could help me out of this jam id be soo greatful
let me know
email me at
danindians@juno.com
: To answer your last line, yes.
: However, it wouldn't be much of a homework assignment if someone else did it for you. Take a stab at it. Ask for help on particular issues or suggestions on a particular question.
: Just dumping an assignment on a message board, though, won't get you very far, especially with the more ethical or more busy of us.
1.) Write a function called StringWrapper that accepts a pointer to a
character array. The purpose of this function is to "wrap" the string
around itself slowly (use delay() in conio.h) in the same position on
the screen for one full cycle of the string. The function prototype
should be:
void StringWrapper(char *String);
Okay, well, for this one you're going to need to have a loop. Since you want to display one full cycle of the string, that means you're going to have the loop operate for as many times as there are characters in the string. So you can determine this value using the strlen() routine.
During the loop, you'll be repositioning the cursor to (1,1). You'll also be displaying some variant of the string. There's a couple of ways to do the output of the string. You can rotate the string in-place. You can also start at some offset from the beginning of the string, write all the characters until the end, and then start again at the beginning until you're back where you started.
2.) Write a function called CaseJumbler accepts a pointer to a
character array and returns the stringin an alternating
uppercase/lowercase format. The function prototype should be:
void CaseJumbler (char *String);
/* PRE : String points to a predefined variable character array.
POST : Returns String with alternating cases for each letter in the
string.
CALLS : Up to designer.......... */
There's a couple of different options here. If you normalize the string first, say by making everything lowercase, then you only have to uppercase every other letter. Otherwise, you'll have to uppercase every other letter and lowercase the others.
You can do either way with two loops. You could even do it in one loop if you're clever, but cleverness sometimes impedes getting it done.
There are two standard routines toupper() and tolower() that both take a character and return its uppercase or lowercase respectively.
3.) Write a function called DecimalToBinary that accepts an unsigned
integer value and prints to the screen the equivalent value in binary
format after converting the value and storing it in a character array.
The function prototype should be:
void DecimalToBinary (unsigned int Value);
/* PRE : Value contains a positive integer.
POST : Prints to the screen the binary equivalence of Value.
CALLS : Up to designer........ */
This isn't as bad as you think it is. There are a bazillion ways to do this. here are a few suggestions.
1) Figure out how to take an integer variable in C and shift its bits left and right. Look into the bitshift operators. Alternatively, examine what happens when you multiply or divide by powers of two. If you can shift a number left and right, you can move certain bits to where you know you want to examine them.
2) Figure out how to examine and alter certain bits within a C integer. The bitwise operators (ampersand, vertical-bar, tilde, and circumflex) might help (this is often referred to as 'masking'). As an alternative, investigate what happens when you use the modulus operator with powers of two, and investigate what happens when you add or subtract powers of two.
Ultimately for this question you have to extract a bit at a time either left to right or right to left and based on the bit's value put a '1' or a '0' in the right spot of the character array.
Hope this helps. If not, ask specific questions. Good luck. It won't be easy if you're not familiar with the language.