Question: Converting integer to character given (int) radix and (int) digit as parameters in C. I'm a bit confused on how this works. The example they

Converting integer to character given (int) radix and (int) digit as parameters in C. I'm a bit confused on how this works. The example they provided states that if radix = 16, value = 10, then the function returns 'A'. That part I understand. The part I'm having trouble with is lets say the radix is 16 and the value is 17. Should I return -1 if thats the case. What if the radix is 2 and the value is 0, 1, or 2. The guidelines also mention that the purpose of the radix value is to validate that the correct return value is given. What does that mean in terms of a value given. How do I implement it?

Is the following correct in terms of relating value to radix?

value=0123456789.............................................................36

char = 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ

The following is the .h documentation file for the .c file.

char int2char (int radix, int value);

/** Return the value corresponding to a character. *

This function should not print anything (you * will lose all points for this function if it does). However, you may print * stuff for your own debugging purposes as long as you remove any printing * statements before you submit.

* @param radix - the base you are working in (2-36) * @param digit - character '0'..'9' or 'A'..'Z' or 'a'..'z' * @return - value in the range of 0 - (radix-1) corresponding to * the given digit if the digit is valid in the given radix. Otherwise return * -1 */

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!