Challenge decimal to octal

sample input and output is correct but on submitting the code i am getting wrong answer on all the test cases

#include
using namespace std;
int oct(int n);
int main() {
int n;
cin>>n;
int no = oct(n);
cout<<no;
return 0;
}
int oct(int n){
int r,no=0;
while(n!=0){
r=n%8;
n/=8;
no=no*10+r;
}
return no;
}

Hi vaibhav
Share your code

#include
using namespace std;
int oct(int n);
int main() {
int n;
cin>>n;
int no = oct(n);
cout<<no;
return 0;
}
int oct(int n){
int r,no=0;
while(n!=0){
r=n%8;
n/=8;
no=no*10+r;
}
return no;
}

Conversion is wrong
For
670 and is 1236
And ur will be 6321