Question: Write one of the following programs in a high-level language (C++ probably best in this case). Do not use any built-in library functions that actually


Writeoneof the following programs in ahigh-level language(C++ probably best in this case). Do not use any built-in library functions that actually accomplish these tasks for you. You may use basiccinandcoutstatements for input and output.

  1. Write a function that receives a string containing a 16bit binary integer. The function must return the strings integer value. Call the function from a driver main program.

this is my coding:

#include using namespace std; int bin16(string m)

{

int b = 1;

int val = 0;

int len = m.length();

for (int p = len - 1; p >= 0; p--) {

if (m[p] == '1')

val += b;

b = b * 2;

}

return val;

}

int main()

{

string n;

cin >> n;

cout

}




Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!