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 |
Is a house a mass structure?
why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???
What is substring in c?
Is c weakly typed?
write a c program to convert fahrenheit to celsius?
what is the importance of spanning tree?
WAP to accept rollno,course name & marks of a student & display grade if total marks is above 200?
How to declare a variable?
Program to display given 3 integers in ascending order
What is a good data structure to use for storing lines of text?
how to find sum of digits in C?
What is wrong with this statement? Myname = 'robin';