Write a C++ program to convert a binary into a decimal number

Description

Write a C++ program to convert a binary number into a decimal number. The program will use the main function arguments as input and print the result.


Example :

given 10111 in binary the program will output 23 decimal


Instructions

  • - use the main function arguments to take the input.
  • - handle errors.
  • - add comments.


Code to start with

// include necessary headers files



int main(/* the arguments here */){
  
    // check main fonction arguments 

    // write the code to print the result

    return 0;
}


Useful Links :

C++ course

C++ main function argument

Binary numbers


  • solution