Error while submitting code

Good morning sir,
I am facing ERROR MESSAGE in the code that I am trying to submit but even after using decimal-octal calculator on internet, My code is getting the same output as shown in internet.
Kindly let me know where I am going wrong because my output is matching with the real octal value.

My Code:

int main(){

int n,a;
cin>>n;
while(n>0){
    a=0;
    a=n%8;
    n=n/8;
    cout<<a;
}

return 0;

}

Hi @arjunanand1526_b304cfe7006d6c21,

    int ans = 0;
    int p = 1;

    while(n>0){
        a=0;
        a=n%8;
        n=n/8;
        ans = ans + a*p;
        p *= 10;
    }

    cout<<ans;

your code is not giving right octal value, for example, take decimal number = 1792
its octal value is 3400 but your code is giving “0043” (i.e its in reverse order)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.