Decimal to octal problem

https://ide.codingblocks.com/s/94739 please kindly check this code

i dont know whats wrong in this code

https://ide.codingblocks.com/s/94739 this is the url of the code

@Ayushi21 hey ayushi try this approach
#include< iostream >
using namespace std;
int main(){
int n;cin>>n;
int ans=0;int p=1;
for( ;n>0;n=n/8){
int last_digit=n%8;
ans=ans+last_digit * p;
p=p * 10;
}
cout<<ans<<endl;
}

please check my code for this problem

@Ayushi21 your code is right just add
int n;
cin>>n;