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
Why are all header files not declared in every c program?
What header files do I need in order to define the standard library functions I use?
What are the differences between new and malloc in C?
Explain about the functions strcat() and strcmp()?
What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?
Explain how can I write functions that take a variable number of arguments?
‘SAVEPOINT’ and ‘ROLLBACK’ is used in oracle database to secure the data comment. Give suitable examples of each with sql command.
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
What are the 5 types of organizational structures?
How many types of functions are there in c?
How can I avoid the abort, retry, fail messages?
Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
Which header file is used for clrscr?
design and implement a data structure and performs the following operation with the help of file (included 1000 student marks in 5 sub. and %also) 1.how many students are fail in all 5 subjects (if >35) 2. delete all student data those are fail in all 5 subjects. 3. update the grace marks (5 no. if exam paper is 100 marks) 4. arrange the student data in ascending order basis of marks. 5.insert double of deleted students with marks in the list.