How to write a program to receive an integer & find its octal equivalent
by using for loop?

Answer Posted / neelkamal

#include"neel.h" // all header file store in neel.h
void rev(int *x) //declaration and body of function
{
int i,t, end=0,a,b;
clrscr();
while(x[end]!=NULL)
end++;
end=end-1;
for(i=0;i<=end/2;i++)
{
t=x[i];
x[i]=x[end];
x[end]=t;
end=end--;
}
i=0;
while(x[i]!=NULL)
{
printf(" %d",x[i]);
i++;
}
}
void main()
{
int x[20];
int n,i=0;
printf("\nenter any int to convert to octal:");
scanf("%d",&n);

for(i=0;i<=20;i++)
{
x[i]=n%8;
n=(n-x[i])/8;
}
rev(x);
getch();

}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do header files do?

606


What is the difference between #include

and #include “header file”?

557


What are the back slash character constants or escape sequence charactersavailable in c?

691


i want to switch my career from quailty assurance engineering to development kindly guide me from which programming language its better for me to start plz refer some courses or certifications too i have an experience of 1.5 yrs in QA field.Kindly guide me

1484


Why does everyone say not to use scanf? What should I use instead?

685






#include int main(){ int i=10; int *ptr=&i; *ptr=(int *)20; printf("%d",i); return 0; } Output: 20 can anyone explain how came the output is 20

1269


Can you subtract pointers from each other? Why would you?

563


largest Of three Number using without if condition?

1012


Do you know the difference between malloc() and calloc() function?

617


What are c header files?

586


FILE *fp1,*fp2; fp1=fopen("one","w") fp2=fopen("one","w") fputc('A',fp1) fputc('B',fp2) fclose(fp1) fclose(fp2)} a.error b. c. d.

1206


Can a file other than a .h file be included with #include?

688


What is character constants?

716


What is hungarian notation? Is it worthwhile?

704


what is different between auto and local static? why should we use local static?

648