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 program to receive an integer and find its octal equivalent?

7 Answers  


#define f(g,g2) g##g2 main() { int var12=100; printf("%d",f(var,12)); }

3 Answers  


Implement a t9 mobile dictionary. (Give code with explanation )

1 Answers   Amazon, Peak6, Yahoo,


#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }

1 Answers  


write a function to give demostrate the functionality of 3d in 1d. function prototye: change(int value,int indexX,int indexY,int indexZ, int [] 1dArray); value=what is the date; indexX=x-asix indexY=y-axis indexZ=z-axis and 1dArray=in which and where the value is stored??

0 Answers   Nagarro,


char inputString[100] = {0}; To get string input from the keyboard which one of the following is better? 1) gets(inputString) 2) fgets(inputString, sizeof(inputString), fp)

1 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  


main() { void swap(); int x=10,y=8; swap(&x,&y); printf("x=%d y=%d",x,y); } void swap(int *a, int *b) { *a ^= *b, *b ^= *a, *a ^= *b; }

2 Answers  


main() { unsigned int i=10; while(i-->=0) printf("%u ",i); }

2 Answers   HP,


void main() { static int i=5; if(--i){ main(); printf("%d ",i); } }

1 Answers  


Write a C function to search a number in the given list of numbers. donot use printf and scanf

5 Answers   Honeywell, TCS,


What are the following notations of defining functions known as? i. int abc(int a,float b) { /* some code */ } ii. int abc(a,b) int a; float b; { /* some code*/ }

1 Answers  


Categories