Octal number system has been popularly used as a potential number system in computing texts,
graphics, and especially file protection systems in UNIX operating system. Develop a C- script that
takes a decimal number as an input and produces its equivalent octal number.
[DoB]10 = (----)8
DoB: Date of birth
Note : Don't use array, do with loops
void ConvertDecToOctal(int num)
{
int j,k=0, OctNum[100];
while (num != 0)
{
OctNum[k] = num % 8;
num = num / 8;
k++;
}
printf("\n\tEquivalent Octal Number = ");
for (j = k - 1; j >= 0; j--) printf("%d ",OctNum[j]);
}
int main()
{
int n = 123;
printf("\n\tDecimal Number = %d",n);
ConvertDecToOctal(n);
return 0;
}
Comments
Leave a comment