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 |
Do character constants represent numerical values?
Difference between pass by reference and pass by value?
Explain why c is faster than c++?
How do we print only part of a string in c?
change to postfix a/(b+c*d-e)
what is structuer?
main() { int i=5; printf("%d%d%d%d",i++,i--,i); }
Why is sprintf unsafe?
If a five digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits.For example if the number that is input is 12391 then the output should be displayed as 23402
main() { enum _tag{ left=10, right, front=100, back}; printf("%d, %d, %d, %d", left, right, front, back); }
what is c programing
If input is 123 then how to print 100 and 20 and 3 seperately?