1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kow [346]
3 years ago
6

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

Computers and Technology
1 answer:
DerKrebs [107]3 years ago
4 0

Answer:

Check the explanation

Explanation:

#include <iostream>

using namespace std;

void hex2dec(string hex_num){

int n = 0;

//Loop through all characters in string

for(int i=0;i<hex_num.size();i++){

//take ith character

char c = hex_num[i];

//Check if c is digit

if(c>='0' && c<='9'){

n = 16*n + (c-48);

}

//Convert c to decimal

else{

n = 16*n + (c-55);

}

}

cout<<hex_num<<" : "<<n<<endl;

}

int main()

{

hex2dec("EF10");

hex2dec("AA");

return 0;

}

The Output can be seen below :

You might be interested in
Each pixel includes 3 colors; Red, Green and Blue. Each color uses 8 bits to store it's intensity. How many Bytes are needed for
PtichkaEL [24]

Answer: 3 bytes

Explanation:

A Pixel uses 3 colors and each of these colors uses 8 bits to store their intensity.

One pixel will therefore have:

= 8 * 3

= 24 bits

1 byte = 8 bits

24 bits will therefore be:

= 24/8

= 3 bytes

6 0
3 years ago
The Department Manager researches new data platforms for the company and requests a list of essential features. Which essential
Ipatiy [6.2K]

Answer:

Centralisation

dashboard , programmatic access

Explanation:

hope it helps u

mark me as brainlist

4 0
3 years ago
What is NOT an issue associated with tag management systems? There is no automation available for tag management systems. Managi
SSSSS [86.1K]

Answer:

Managing tags means experience with the programming language to utilize them.

Explanation:

In different markets, tags are used to assigned prices and values to different products. To make these tags "tag management systems" are deployed to manage and create these tags.

Tag management system is software, that is used to create the tags with ease. There is no need of coding or programming while creating tags.

<em>So we can say that, There is no issue of Managing tags means experience with the programming language to utilize them.</em>

5 0
3 years ago
Which part of the cryosphere comes directly from the atmosphere?
marin [14]
The answer to this question is C.
4 0
3 years ago
Read 2 more answers
which process consists of one application program following a logical access path (lap) and then a dbms following a physical acc
laiz [17]

A DBMS acts as a conduit between the database and the applications that will use it, enabling users to access, modify, and control how the data is arranged and optimized.

Data points that are connected to one another are stored and accessible in a relational database, which is a form of database. The relational model, an easy-to-understand method of representing data in tables, is the foundation of relational databases. Data items are requested from the database by application programs, which are created using a combination of the DBMS's data manipulation language and a traditional programming language. The DBMS locates and provides the data elements requested by the application programs.

Learn more about database here-

brainly.com/question/6447559

#SPJ4

5 0
1 year ago
Other questions:
  • You are preparing to program a replacement system board, but the "system is booting in mpm mode" message is not displayed. what
    10·2 answers
  • What happens if you have you an image that has 6 bits-per-pixel and you change it to 12
    6·1 answer
  • A gas furnace has an efficiency of 75% . How many BTU will it produce from 1000 BTU of natural gas​
    14·2 answers
  • IF YOU PLAY SURVIV&gt;IO WITH ME RIGHT NOW I WILL GIVE YOU BRAINLIEST<br> AND IM NOT KAPPING
    5·1 answer
  • Adam is an Engineering student but has decided that he does not want to work in that field, but in the Manufacturing career clus
    11·2 answers
  • An end-user license agreement protects _____.
    7·1 answer
  • Please help it’s timed
    5·1 answer
  • FIRST TO Answer for free brainlest. GOG GOGOGO
    6·1 answer
  • What does this map key show
    12·1 answer
  • The output of a computer can be seen on ( monitor, keyboard or mouse )​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!