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 is the difference between #include<stdio.h> and #include "stdio.h" ?

3 Answers  


What is false about the following A compound statement is a.A set of simple statments b.Demarcated on either side by curly brackets c.Can be used in place of simple statement d.A C function is not a compound statement.

5 Answers   CCEM, TCS,


What is keyword in c?

1 Answers  


coding for Fibonacci.?

1 Answers  


How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

1 Answers  


to find the closest pair

1 Answers   Infosys,


Suppose I want to write a function that takes a generic pointer as an argument and I want to simulate passing it by reference. Can I give the formal parameter type void **, and do something like this? void f(void **); double *dp; f((void **)&dp);

1 Answers  


write a program to check whether a number is Peterson or not.

4 Answers  


What is the difference between printf and scanf in c?

1 Answers  


difference between my-strcpy and strcpy ?

3 Answers   Geometric Software, IIM, Infosys,


What is the data segment that is followed by c?

1 Answers  


differentiate between const char *a; char *const a; and char const *a;

2 Answers   College School Exams Tests, HCL, TCS,


Categories