Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi Im having trouble with this problem. So far I wrote the first function and its not working well. And I also need help with

Hi Im having trouble with this problem. So far I wrote the first function and its not working well. And I also need help with the second function.
Write a c++ program to convert binary numbers to decimal and decimal numbers to binary. You need to create two functions bin_to_dec and dec_to_bin.
bin_to_dec should take a binary number as a STRING and then convert it to an INT as a decimal number.
Dec_to_bin should take a decimal number as an INT and then convert it to a STRING as a binary number.
NOTE: These functions should only convert Unsigned(positive) numbers. DO NOT worry about signed numbers.
Thanks in advance.
image text in transcribed
image text in transcribed
int bin to dec(string s) INPUT(S): an UNsigned binary number as a string (e.g., "10110001") RETURN(S): the binary number converted to the equivalent decimal number PURPOSE: Converts any UNsigned binary number to decimal string dec to bin int n) INPUT(s): A non-negative decimal number (e.g, 15) RETURN(S): The decimal number converted to the equivalent binary number (as a string) PURPOSE: Converts any non-negative decimal number to binary

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

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions