i am not able t form the code for this problem.pls tell
Decimal to octal challenge
Hey @yutikakhanna
The code for decimal to octal conversion is as follows:
#include
using namespace std;
void decToOctal(int n)
{
// array to store octal number
int octalNum[100];
// counter for octal array
int i = 0;
while (n > 0) {
// storing remainder in octal array
octalNum[i] = n % 8;
n = n / 8;
i++;
}
// printing binary array in reverse order
for (int j = i - 1; j >= 0; j--)
cout << octalNum[j];
}
// Driver program to test above function
int main()
{
int n;
cin >> n
decToOctal(n);
return 0;
}