Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

this is my code: #include <iostream> #include <cstdlib> #include <cmath> using n

ID: 3608775 • Letter: T

Question

this is my code:
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

/**
* When it is finished, this program will read a number in thebinary system
* and print its
* decimal representation.
*/

void binToDec(int binaryNumber, int& decimal, int&weight);
int main()
{
   // Variables declaration
   int binaryNum;
    int decimalNum;
    int bitWeight;
  
    decimalNum = 0;
    bitWeight = 0;
  
   // Get the binary number
   cout << "Enter a binary number: ";
   cin >> binaryNum;
   cout << endl;
  
   // Calculate/print its decimalrepresentation

    binToDec(binaryNum, decimalNum, bitWeight)
    cout << "Binary " << binaryNum<< " = " << decimalNum << " decimal" <<endl;
    system("PAUSE");
    return 0;
}
  
void binToDec(int binaryNumber, int& decimal, int&weight)
{
         int bit;
       
         if(binaryNumber>0);
         {
            bit = binaryNumber%10;
            decimal = decimal
                    +bit * static_cast<int>(pow(2.0, weight));
            binaryNumber = binaryNumber / 10;
            weight++;
            binToDec(binaryNumber, decimal, weight);
         }
    }

If there is a easier way to do this could you show me the code.Hopefully you can fix my problem so i can view the output when iexecute it.

Explanation / Answer

please rate - thanks I made a couple of minor changes. I tried to highlight all of them.This was actually very good int main() {     // Variables declaration     int binaryNum;     int decimalNum;     int bitWeight;        decimalNum = 0;     bitWeight = 0;        // Get the binary number     cout > binaryNum;     cout