3
I need to create an algorithm that converts decimal to octal, but my ta converting wrong, someone can help me as it would 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;
}
I got it, bro, I forgot to multiply by 10 and initialize the octal and i, vlw ai
– flavio