Hi everyone. I am trying to create a program to convert numbers into base 8 using a function but it outputs 0 every time. I cannot figure out why. Can someone help me with the code below?
#include <iostream>
#include <cstdlib>
using namespace std;
int convert(int);
int main()
{
int dummy;
int base10;
cout << "Enter your base 10 number" << endl;
cin >> base10;
cout << "Your number " << base10 << " is " << convert(base10) << " in base 8";
cin >> dummy;
return 0;
}
int convert(int a)
{
int base8 = 0;
int number;
number = a;
int remainder=0;
a % 8 == remainder;
base8 = base8 + remainder;
return base8;
a = int(a / 8);
a % 8 == remainder;
base8 = base8 + (remainder * 10);
return base8;
a = int(a / 8);
a % 8 == remainder;
base8 = base8 + (remainder*100);
a = int(a / 8);
return base8;
}