I need to create an algorithm that converts decimal to octal, but my conversion is wrong, can anyone help me how would it be right?
#include <stdio.h>
int decim(int n)
{
int i,a;
int octal;
if(n<=7)
{
octal=n;
}
else
{
while(n>=8 )
{
a=n%8;
n=n/8;
}
n=n%8;
}
return octal;
}
int main()
{
int n,octal;
printf("Informe um numero decimal:");
scanf("%d",&n);
octal=decim(n);
printf(" o numero octal eh: %d\n",octal);
return 0;
}