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
Savatey [412]
3 years ago
9

Implement function bin2dec that takes a binary number bin_num as a string argument and prints out the corresponding decimal numb

er. Each char in the string has a value of either '0' or '1' to represent a bit. The string does not have any leading space. For example, function call bin2dec("1011") should print 11. You can assume that bin_num can have up to 32 bits. To convert a char in the binary number string to an int, you can subtract the char by '0'. For example, you can use bin_num[0] - '0' to get the int value of the most significant bit of the binary number. Restriction: printf is the ONLY C library function that you can use in the implementation.
Computers and Technology
1 answer:
andriy [413]3 years ago
7 0

Answer:

See explaination

Explanation:

void bin2dec(char *s) {

int i = 0, num = 0;

while (s[i]) {

num *= 2;

num += s[i] - '0';

i++;

}

printf("%d\n", num);

}

The program Implement function bin2dec that takes a binary number bin_num as a string argument and prints out the corresponding decimal number.

You might be interested in
An excel user should use a relative cell reference when it is important to ____. preserve the relationship to the formula locati
adell [148]

An excel user should use a relative cell reference when it is important to preserve the relationship to the formula location. When you create a formula that references other cells, excel does not normally "record" the exact cell address. Instead, it looks at the at the relationship that cell has to the other cell containing the formula.

7 0
3 years ago
Conduct online research and provide some guidelines on how to secure a web browser. (CyberSecurity plato)
Mashcka [7]

Answer:

RTX 3090

Explanation:

7 0
3 years ago
Which of the following is a system management tool?
JulsSmile [24]
What’s are the options??
3 0
3 years ago
Read 2 more answers
What is the name of the item that supplies the exact or near exact voltage at the required wattage to all of the circuitry insid
gizmo_the_mogwai [7]

Answer:

It's the <u><em>power supply</em></u>

Explanation:

The power supply is what essentially enables the computer to operate. It is able to do that by converting the incoming alternating current (AC) to direct current (DC) at the correct wattage rating that is required by the computer to function. The power supply is a metal box that is generally placed in the corner of the case.

4 0
3 years ago
An information system can enhance core competencies by
Nutka1998 [239]

Answer:

An information system can enhance core competencies by: encouraging the sharing of knowledge across business units.

Explanation:

Hope this helps you ! please mark me brainless

4 0
2 years ago
Other questions:
  • When called upon to give an impromptu speech, it is a good idea to do all of the following, except:
    11·2 answers
  • Click _______ to view each individual record of a mail merge document.
    5·2 answers
  • Three variables, x, y and z, supposedly hold strings of digits, suitable for converting to integers. Write code that converts th
    7·1 answer
  • Lydia noticed that she feels tired and out of breath after walking her dog up a hill in the park. Which area of fitness does she
    8·1 answer
  • Richard needs to copy information from another slide presentation that uses a different design template. To ensure that the info
    7·1 answer
  • How to wire two separate switches &amp; lights using the same power source?
    14·1 answer
  • When looking at aggregated logs, you are seeing a large percentage of Windows hosts connecting to an Internet Protocol (IP) addr
    5·1 answer
  • What did Bakers wear (1) in the Portugal does (2) when was author was young ???
    10·1 answer
  • What makes a source credible?
    9·2 answers
  • What is the difference between referential and entity integrity
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!