ARI C++ Code
ARI C++ Code
ARI C++ Code
h>
#include<conio.h>
#include<string.h>
#include<math.h>
#include<process.h>
void main()
{
clrscr();
int a,base,x,i,j,k,l,sum;
long num;
sum=0;
cout<<"Enter the base and number: ";
cin>>base>>num;
j=0;
if(base>=2&&base<=10)
{
do{
a=num%10;
num=num/10;
if(a>=base)
{
cout<<-1;
getch();
exit(0);
}
sum=sum+(a*pow(base,j));
j++;
}while(num!=0);
cout<<sum;
}
else
{
cout<<-1;
}
getch();
}