Please help me my teacher gave me a program and I don't know how to do it. So this the program the she gave me.

Do you know how to do this on paper? Do you understand what is meant by a number being in a base other than base 10?

Yeah I know this on paper. But making a program with it I can't. And my teacher said it should be in array.

learning to do it in code is what you're taking those classes for. So go ahead and try...
If you just wait for others to do it for you and hand in what they have done as your own you've learned nothing except how to be a dishonest, cheating, lazy, profiteering, liar.

Heres's my program and I don't if this right or wrong. And plus I need this to be in array.

``````#include<iostream.h>
#include<conio.h>
int convert(int a,int base)
{
int sum=a%10;
for(int i=base;(a/=10)!=0;i*=base)
sum+=a*i;
return sum;
}

int main()
{
int a,base,ans;

cout << "Enter a number: ";
cin >> a;

cout << "Enter a base: ";
cin >> base;

ans=convert(a,base);

cout << "the converted base 10 is"<<ans;
getch();
return 0;
}
``````

Here, this should pretty much clear everything uncertain about converting any number to base 10: Click Here

Also, your function is wrong, don't rush through steps, it will get you confused:

``````#include <cmath>
int ToBase10(int number, int base){
int ret = 0;                        //return number;
for (int i = 0; i < base; i++){     //loop for computing the base power