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 we can insert comments in a c program?
What are volatile variables in c?
find out largest elemant of diagonalmatrix
Why we write conio h in c?
Wt are the Buses in C Language
What is variables in c?
How does #define work?
Explain what does the function toupper() do?
What does dm mean sexually?
Write a program to swap two numbers without using the third variable?
What are reserved words?
What is structure packing in c?
What is a null pointer in c?
how to print the character with maximum occurence and print that number of occurence too in a string given ?
What tq means in chat?