Question: Code in C please Create a function convertDecToHex() that takes an integer as input, and returns an array of integers that represent the number in
Code in C please
Create a function convertDecToHex() that takes an integer as input, and returns an array of integers that represent the number in hexadecimal, where each element in the array is one digit of the hexadecimal number. For example, if the number 65292 is passed into the function, the function should return the integer array [0xF,0xF,0x0,0xC] or [15, 15, 0, 12]. The function should be named convertDecToHex, case matters. The function only needs to handle positive numbers from 0 to 65,535 (fits in 16 bits), therefore, the size of the array only needs to be 4 elements. There is a helper #define NUM BER_OF_ HEX_DIGITS 4 for this purpose. Use the dereference syntax and pointer arithmetic to access array elements: *(myarr + i). Use malloc() to allocate memory on the heap for the return array. You can use the division or subtraction method for the number conversion.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
