Decimal to octal

why it is not passing testcases though output is correct
#include
using namespace std;
int main() {
int no;
cin>>no;
while(no>0)
{int r=no%8;
cout<<r;
no=no/8;
}
return 0;
}

@9999082753 hey sahil you need a variable to add your result like ans =0;
ans=ans+last_digit and you need a power variable to multiply into the answer variable.

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.