C Program to Convert Decimal Number into Octal



The octal numeral system is the base-8 number system, and uses the digits 0 to 7.



  1. //C program to convert decimal to octal
  2. #include <stdio.h>
  3. int main()
  4. {
  5. long decinum, remainder, quotient;
  6. int octnum[100], i = 1, j;
  7. printf("Enter the decimal number: ");
  8. scanf("%ld", &decinum);
  9. quotient = decinum;
  10. while (quotient != 0)
  11. {
  12. octnum[i++] = quotient % 8;
  13. quotient = quotient / 8;
  14. }
  15. printf("Equivalent octal value of decimal no %d: ", decinum);
  16. for (j = i - 1; j > 0; j--)
  17. printf("%d", octnum[j]);
  18. return 0;
  19. }

Output
Output!
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


Join Our Facebook Group


Share this example


Download Android App

download android app

Popular C Examples









codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube