hey my name is duplaix..am new in c++ so i need help!

I have to write the following set of c++ functions

 fromBinaryToDecimal: The function must accept a pointer to a one-dimensional, dynamically allocated, Boolean array together with an integer representing its length as parameters. You may assume that the array represents a positive value. The function’s return value is an unsigned integer.
 fromDecimalToBinary: The function receives an unsigned integer as a parameter and returns a string.
 fromHexToBinary: The function receives a string as a parameter and returns a string. Your function must check to make sure that the incoming string represents a valid hexadecimal value.
 fromBinaryToHex: The function must accept a pointer to a one-dimensional, dynamically allocated, Boolean array together with an integer representing its length as parameters. You may assume that the array represents a positive value. The function’s return value is a string.
 Overloaded versions of the fromBinary* functions which accept a string parameter.
 A main function in a separate cpp file which demonstrates the use of your functions via a menu system.

Welcome to DaniWeb!

You won't likely get any help here unless you show us that you have given it a good try yourself first. Post some code that you have come up with and explain the input, current output, and expected output along with any compiler errors or crashes and we'll try to help you out.

Good luck,

Dave

>>fromBinaryToDecimal

To convert from binary to decimal you use the expansion rule.

For example : convert "1010" to its decimal value.

To convert 1010 into a decimal value, we note the position of each bit.

3 2 1 0 //position of each bit
1 0 1 0  //binary number

Now we use the general expansion rule:
To convert from binary to decimal the general rule is: a0 * 2^x + a1* 2^(x-1) ...
ax * 2^0, there "^" represent the power function, and x represent the bits position, and ax is the bits coefficient at its position.

So to convert 1010 to decimal we do:

1*2^3 + 0*2^2 + 1*2^1 + 0*2^0

1*8 + 0*4 + 1*2 + 0*1

8 + 0 + 2 + 0 = 10

Thus the binary number 1010 in decimal base is 10.

Now turn that math into C++ code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.