This article is from solution of Let Us C by Yashwant Kanetkar. I also posted many another articles regarding solutions of Let Us C. If you have any problem regarding solution then give comment, I will surely reply your question.
Q. Write a program to receive an integer and find its octal equivalent.
Ans.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n, oct[10], quo, i=0, j=-1;
printf("Enter any number ");
scanf("%d",&n);
quo=n;
while(quo!=0)
{
oct[i]=quo%8;
quo=quo/8;
i++;
j++;
}
printf("\nOctal Equilvalent Is\n");
for(;j>=0;j--)
{
printf("%d",oct[j]);
}
getch();
}