Hello fellow programmers :))
just started c++ a month ago and in need of major helpzz!!
so basically I need code that:
INPUT NUMBER-->BASE OF NUMBER-->PRINTS DECIMAL REPRESENTATION OF IT
Im trying this code..when i put any number and base I just get 0
pleaxxxx help!!!
ty all!!
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
string inp;
int j;
int dec=0; //store
char base;
cout << "input number: ";
cin >> inp;
cout << "input base: ";
cin >> base;
for (int i = inp.length ()-1; j == 0; ++j) dec += (inp[i]-48) * pow ((float) base-48,j);
cout << "your number in base 10 is: " << dec << endl;
return 0;
}