How to print octal number in c

Using %o format specifier in printf, we can print the octal numbers.




%o

Example

#include<stdio.h>

int main()
{
    int i = 10;

    printf("%d in Octal = %o\n",i,i);

    return 0;
}

Output

10 in Octal = 12


8 | 10
  -----
  |   1   -  2
  -----
  (12)8
                          



Useful Resources

https://www.log2base2.com/number-system/octal-number-system.html

Topics You Might Like