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]
2 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]2 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
Which of the following was the first full-length film to be done completely in 3-D imaging
motikmotik
Toy story I believe is the answer
6 0
2 years ago
Read 2 more answers
Which of the following is the most effective password?
zzz [600]
I would have to say that the M3(ury would be the MOST effective, because it has more capitals, numbers, and symbols, which would make it harder to hack into.
5 0
3 years ago
Read 2 more answers
="Jack"&"$"&"Jill". What will be the output of this formula?​
natita [175]
I’m so confused on this but hey here’s this

3 0
2 years ago
An___ is a rectangular work area in the desk top that contains a program, text, files, it other data and tools.
Nataly_w [17]
A window is a rectangular work area in the desk top that contains a program, text, files, it other data and tools.
Hope this helps!
5 0
3 years ago
PLEASE HURRY!!<br> Look at the image below
levacccp [35]
Answer is power and base

Explanation: both power and base are number variables
8 0
2 years ago
Other questions:
  • __ is/are the amount of blank space between lines of text in a paragraph
    7·2 answers
  • Network is a process by which several protocols evolve to form a single product.
    13·1 answer
  • What are the advantages of Napier bones?​
    15·1 answer
  • In a meeting, Juan hears someone say a product mix is "wide." What does
    13·1 answer
  • Write a statement that compares the values of score1 and score2 and takes the following actions. When score1 exceeds score2, the
    7·1 answer
  • Which of the following provides services to hosts on its network?
    9·1 answer
  • Select one or more of the following: Which of these events will cause signal(s) to be generated by the kernel (the operating sys
    6·1 answer
  • Selma writes the following four answers in her Computer Science examination.
    8·2 answers
  • You are given a graph G = (V, E) with positive edge weights, and a minimum spanning tree T = (V, E’) with respect to these weigh
    14·1 answer
  • What does it mean when the lottery machine says function suppressed after scanning a ticket
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!