Write a program to receive an integer and find it's octal
equivalent.
How can i do with using while loop.
Answers were Sorted based on User's Feedback
Answer / mithun shrivastav
#include<stdio.h>
void main()
{
int n,sum = 0,rev = 0;
print("\nEnter an Integer No. : ");
scanf("%d", &n);
while(n>0)
{
sum = sum * 10 + n%8;
n = n/8;
}
while(sum > 0)
{
rev = rev*10 + sum%10;
sum = sum/10;
}
printf("Octal Equivalent = ", rev);
getch();
}
Is This Answer Correct ? | 19 Yes | 16 No |
int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().
Implement a t9 mobile dictionary. (Give code with explanation )
1 Answers Amazon, Peak6, Yahoo,
main( ) { int a[ ] = {10,20,30,40,50},j,*p; for(j=0; j<5; j++) { printf(“%d” ,*a); a++; } p = a; for(j=0; j<5; j++) { printf(“%d ” ,*p); p++; } }
main() { signed int bit=512, mBit; { mBit = ~bit; bit = bit & ~bit ; printf("%d %d", bit, mBit); } } a. 0, 0 b. 0, 513 c. 512, 0 d. 0, -513
3 Answers HCL, Logical Computers,
main() { int a=10,*j; void *k; j=k=&a; j++; k++; printf("\n %u %u ",j,k); }
why is printf("%d %d %d",i++,--i,i--);
main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }
Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).
13 Answers Intel, Microsoft, TCS,
Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.
16 Answers Aricent, Cisco, Directi, Qualcomm,
void main() { int i=10, j=2; int *ip= &i, *jp = &j; int k = *ip/*jp; printf(“%d”,k); }
main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }
9 Answers CSC, GoDB Tech, IBM,
prog. to produce 1 2 3 4 5 6 7 8 9 10