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

WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER

0 Answers  


Do you have any idea about the use of "auto" keyword?

0 Answers  


write a progam to compare the string using switch case?

1 Answers  


write aprogram for There is a mobile keypad with numbers 0-9 and alphabets on it. take input of 7 keys and then form a word from the alphabets present on those keys.

1 Answers   iGate, Shashi, Source Bits, Subex,


input any 4 digit number and find the difference of all the digits?

3 Answers   Google,






How to receive strings with spaces in scanf()

7 Answers  


The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference

0 Answers  


State the difference between x3 and x[3].

0 Answers   Aricent,


how can i get the string which is having two spaces at the end.suppose the string is "Hello World ".Now at the end i have two spaces.i need to print with that spaces .

1 Answers  


Explain null pointer.

0 Answers  


Explain modulus operator. What are the restrictions of a modulus operator?

0 Answers  


What are the ways to a null pointer can use in c programming language?

0 Answers  


Categories