Previously said:
please~help me to write a program to convert the baseN(2-9) to base10
eg. 101(2)----->5(10)
1211(3)------->X(10)
.....
P.S. i am really misunderstand the C programming, plz write the simple
statments as you can
If you have a value "abc" representing a value inbaseX, then theconversioncan be expressed as this:-
(((a * X) + b) * X) + c
So all you need to do (excluding handling invalid input, negative
values and the like), is to take a digit at a time from the left of
the input string and add its numeric value to a running total,
multiplying by thebaseeach time round.
Try producing some code to do this, and get back to us.
For simplicity, pass the value to be converted and thebaseas
arguments to the program, so you don't need any input I/O - you can
just use argv[1] and argv[2], for example. You'll want something like
atoi() or strtol() to convert thebaseto an integer or long, but the
value to convert is probably easier handled as a string.