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
What is a pointer variable in c language?
Can you return null in c?
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given
What is variable and explain rules to declare variable in c?
what do the 'c' and 'v' in argc and argv stand for?
Explain what happens if you free a pointer twice?
What is NULL pointer?
Can a variable be both static and volatile in c?
Which is the memory area not included in C program? give the reason
Write a c program to build a heap method using Pointer to function and pointer to structure ?
Which is better pointer or array?
I have seen function declarations that look like this
how to print the character with maximum occurence and print that number of occurence too in a string given ?
What is the difference between if else and switchstatement
What is the use of typedef in structure in c?