Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Design Operation And Evaluation Of Mobile Communications

Authors: Gavriel Salvendy ,June Wei

1st Edition

3030770249, 978-3030770242

More Books

Students also viewed these Programming questions

Question

What is unrealistic about the domino fault model?

Answered: 1 week ago

Question

Why is UDP needed? Why cant a user program directly access IP?

Answered: 1 week ago