Question: 2 Integer to Quaternary String Write the C function itoq) to covert an integer to a quaternary string. Its prototype is described in the header

 2 Integer to Quaternary String Write the C function itoq) to

covert an integer to a quaternary string. Its prototype is described in

2 Integer to Quaternary String Write the C function itoq) to covert an integer to a quaternary string. Its prototype is described in the header file itox.h. Write your code in the file 1tox.c. You can build from the stub itox.c from my hw3 directory. The idea behind itoq) is to convert an int variable (an int has 32 bits on our machine) directly to an ASCII string of quaternary digits, '0', ..., '3. In this assignment, we will consider only positive integers. The algorithm is as follows. 1. Divide the int by 4 2. The remainder is the first quaternary digit, to be placed in quaternaryStr [15] Use '0' to represent remainder 0, ' for remainder 1, and so on. 3. Update the int to be the quotient 4. Repeat steps 1, 2, and 3 for s1zeof (1nt) 4 times. When Step 2 is executed for the second time, the quaternary digit will go into quaternaryStr [14 when Step 2 is executed for the third time, the hex digit will go into quaternaryStr [13]; and so on. 5. Terminate quaternaryStr with \o. Note that the array quaternaryStr declared by the caller can be declared with a size sizeof (int) *4 1. sizeof ) is evaluated at compile time to be the number of bytes in a variable of a given type. For example, it is 4 bytes to an int on our machine, but it might be 8 bytes on a different machine. Thus sizeof ) allows your code to be portable

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!