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



Write a program to receive an integer and find it's octal equivalent. How can i do with using..

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

Write a program to receive an integer and find it's octal equivalent. How can i do with using..

Answer / nitin sokhal

This program is Correct

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More C Code Interview Questions

main() { { unsigned int bit=256; printf("%d", bit); } { unsigned int bit=512; printf("%d", bit); } } a. 256, 256 b. 512, 512 c. 256, 512 d. Compile error

1 Answers   HCL,


main() { char * strA; char * strB = I am OK; memcpy( strA, strB, 6); } a. Runtime error. b. I am OK c. Compile error d. I am O

4 Answers   HCL,


main() { int i=3; switch(i) { default:printf("zero"); case 1: printf("one"); break; case 2:printf("two"); break; case 3: printf("three"); break; } }

1 Answers  


main() { int i; clrscr(); for(i=0;i<5;i++) { printf("%d\n", 1L << i); } } a. 5, 4, 3, 2, 1 b. 0, 1, 2, 3, 4 c. 0, 1, 2, 4, 8 d. 1, 2, 4, 8, 16

4 Answers   HCL,


main( ) { int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}}; printf(ā€œ%u %u %u %d \nā€,a,*a,**a,***a); printf(ā€œ%u %u %u %d \nā€,a+1,*a+1,**a+1,***a+1); }

2 Answers  






main() { int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i); } a. 20, 10, 20, 10 b. 20, 9, 20, 10 c. 20, 9, 19, 10 d. 19, 9, 20, 10

4 Answers   HCL,


There are 21 people in a room. They have to form groups of 3 people each. How many combinations are possible? Write a C program to print the same.

1 Answers   TCS,


How we print the table of 3 using for loop in c programing?

7 Answers  


Write a routine that prints out a 2-D array in spiral order

3 Answers   Microsoft,


main() { int i=5; printf("%d",++i++); }

1 Answers  


void main() { void *v; int integer=2; int *i=&integer; v=i; printf("%d",(int*)*v); }

1 Answers   Honeywell,


main(){ unsigned int i; for(i=1;i>-2;i--) printf("c aptitude"); }

2 Answers  


Categories