luc032.c (776B)
1 /* Write a program to recieve an integer and find its octal equivalent. 2 (Hint : To obtain octal equivalent of an integer, Divide it continuously 3 by 8 till dividend does not become zero, then write the remainders 4 obtained in reverse derection.) */ 5 /* Let Us C, Chap- 5, Page - 87, Qn No.: B(e) */ 6 7 // using array 8 9 #include <stdio.h> 10 int main() 11 { 12 int octal[20], decimal, index = 0, temp, rem; 13 printf("Enter the decimal number : "); 14 scanf("%d", &decimal); 15 temp = decimal; 16 while (temp != 0) 17 { 18 rem = temp % 8; 19 temp = temp / 8; 20 octal[index] = rem; 21 index++; 22 } 23 printf("\nDeciaml %d to octal : ", decimal); 24 while ((index - 1) >= 0) 25 { 26 printf("%d", octal[index - 1]); 27 index--; 28 } 29 return 0; 30 }