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

Write a C program to add two numbers before the main function is called.

11 Answers   Infotech, TC,


Find your day from your DOB?

15 Answers   Accenture, Microsoft,


Find the largest number in a binary tree

7 Answers   Infosys,


Cluster head selection in Wireless Sensor Network using C programming language.

0 Answers  


Sorting entire link list using selection sort and insertion sort and calculating their time complexity

1 Answers   Infosys, Microsoft, NetApp,


main() { char *cptr,c; void *vptr,v; c=10; v=0; cptr=&c; vptr=&v; printf("%c%v",c,v); }

1 Answers  


/*what is the output for*/ void main() { int r; printf("Naveen"); r=printf(); getch(); }

4 Answers  


You are given any character string. Find the number of sets of vowels that come in the order of aeiou in the given string. For eg., let the given string be DIPLOMATIC. The answer returned must be "The number of sets is 2" and "The sets are "IO and AI". Vowels that form a singleton set must be neglected. Try to post the program executable in gcc or g++ or in java.

3 Answers  


program to Reverse a linked list

12 Answers   Aricent, Microsoft, Ness Technologies,


Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.

16 Answers   Aricent, Cisco, Directi, Qualcomm,


main() { int i = 100; clrscr(); printf("%d", sizeof(sizeof(i))); } a. 2 b. 100 c. 4 d. none of the above

5 Answers   HCL,


void main() { char a[]="12345\0"; int i=strlen(a); printf("here in 3 %d\n",++i); }

3 Answers  


Categories