subject

Implement function hex2dec that takes a hex number hex_num as a string argument and prints out the corresponding decimal number. Each char in the string represents one of the 16 hex digits: '0', '1', '2', '3', ..., 'A', 'B', 'C', 'D', 'E', 'F'. No lower case letters will be used in the string. The string does not have any leading space nor the prefix "0x". For example, function call hex2dec("EF10") should print 61200. You can assume that hex_num can have up to 8 hex digits. To convert a char in the hex number string to an int, you need to check whether the char is in the range of '0' to '9'. If so, you can subtract the char by '0' to get its corresponding number. Otherwise, you need to subtract the char by 'A' and then add 10 to get its corresponding value. For example, you can use hex_num[0] - 'A' + 10 to get the int value for the most significant digit of the hex number, if the digit is between 'A' and 'F'. Restriction: printf is the ONLY C library function that you can use in the implementation. Restrictions:- printf is the ONLY C library function that you can use in the implementation (no scanf)- no pow() function - cannot add additional code to the int main() to test code - you can only call the function

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 09:50, brennarfa
17. implement the jvm dload instruction for the mic-2. it has a 1-byte index and pushes the local variable at this position onto the stack. then it pushes the next higher word onto the stack as well
Answers: 2
image
Computers and Technology, 22.06.2019 19:20, manny2085
Amedian in the road will be marked with a white sign that has a black arrow going to the left of the median. true false
Answers: 1
image
Computers and Technology, 22.06.2019 19:30, bstine6678
When creating a presentation in libre office impress, where does the editing of slides take place? a. the slides panel b. the center panel c. the tasks panel, under the masters pages tab d. the tasks panel, under the layouts tab
Answers: 1
image
Computers and Technology, 23.06.2019 09:30, nsjcbdhcb
Light travels at a speed of 186,000 miles a second. the distance light travels in a year is 5,865,690,000,000 miles/year 5,865,695,000,000 miles/year 58,656,950,000,000 miles/year 6,789,000,0000 miles/year
Answers: 1
You know the right answer?
Implement function hex2dec that takes a hex number hex_num as a string argument and prints out the c...

Questions in other subjects:

Konu
Mathematics, 14.04.2020 21:05
Konu
Mathematics, 14.04.2020 21:05