Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

What does it mean when a numeric constant in C/C++ is prefixed with a 0?


1 Answer
Smita Kapse

Sometimes we may see some numeric literals, which is prefixed with 0. This indicates that the number is octal number. So octal literals contain 0 at the beginning. For example, if an octal number is 25, then we have to write 025.

Example

#include <stdio.h>
int main() {
   int a = 025;
   int b = 063;
   printf("Decimal of 25(Octal) is %d\n", a);
   printf("Decimal of 63(Octal) is %d\n", b);
}

Output

Decimal of 25(Octal) is 21
Decimal of 63(Octal) is 51

Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.