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
How do you do dynamic memory allocation in C applications?
How do you list files in a directory?
What is a macro, and explain how do you use it?
What is the difference between text and binary modes?
Write a program to check armstrong number in c?
How can I avoid the abort, retry, fail messages?
List some applications of c programming language?
Explain the difference between getch() and getche() in c?
What is the usage of the pointer in c?
Not all reserved words are written in lowercase. TRUE or FALSE?
Write a code to remove duplicates in a string.
Explain can you assign a different address to an array tag?
What is a constant?
why wipro wase
The file stdio.h, what does it contain?