Decimal to octal conversion

The following program takes a decimal number as an input and prints its octal equivalent. This program is implemented using c.

Code:

#include<stdio.h>

int main()
{
int n,a[100],i,j;
printf("Enter a decimal number : ");
scanf("%d",&n);
for (i=0;n!=0;i++)
{
a[i]=n%8;
n=n/8;
}
printf("The octal equivalent is : ");
for (j=i-1;j>=0;j--)
{
printf("%d",a[j]);
}
return 0;
}


Output:

Bikash Panda
Catch Me On

Bikash Panda

Blogger / Embedded System Developer at WeArGenius
A techie, tinkerer and tech lover, who loves to blog and feels everyone can learn tech provided they have the right attitude towards learning and passion. By profession, I am an IOT developer working in Smart Home/ Smart Grid domain.
Bikash Panda
Catch Me On

Latest posts by Bikash Panda (see all)

Bikash Panda

A techie, tinkerer and tech lover, who loves to blog and feels everyone can learn tech provided they have the right attitude towards learning and passion. By profession, I am an IOT developer working in Smart Home/ Smart Grid domain.