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


Please Help Members By Posting Answers For Below Questions

How we can insert comments in a c program?

634


What are volatile variables in c?

522


find out largest elemant of diagonalmatrix

1651


Why we write conio h in c?

568


Wt are the Buses in C Language

2753






What is variables in c?

609


How does #define work?

650


Explain what does the function toupper() do?

636


What does dm mean sexually?

814


Write a program to swap two numbers without using the third variable?

598


What are reserved words?

656


What is structure packing in c?

608


What is a null pointer in c?

598


how to print the character with maximum occurence and print that number of occurence too in a string given ?

2036


What tq means in chat?

583