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



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

Answer / 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

More C Interview Questions

what do the 'c' and 'v' in argc and argv stand for?

0 Answers   TISL,


What are the types of data structures in c?

0 Answers  


Who had beaten up hooligan "CHAKULI" in his early college days?

1 Answers  


Difference between goto, long jmp() and setjmp()?

0 Answers   EXL,


for example user gives input as " 20 or 20.0 or rs 20.0 or 20.00 or rs20 and so .. on " and the output should be stored as " rs.20.00 " in a variable

2 Answers  


name the language for writing c compiler?

3 Answers   Microsoft,


Is it possible to run using programming C for Java Application?

2 Answers   NIC,


What are c preprocessors?

0 Answers  


disadvantages of realloc ?

1 Answers   HCL,


Is a pointer a kind of array?

0 Answers  


How can I increase the allowable number of simultaneously open files?

1 Answers   CSC,


Why do u use # before include in a C Progam?

9 Answers   IBM,


Categories