Can you explain it? Why it given 56 value as output?
#include <stdio.h>
#include <conio.h>
void main()
{
int x = 070;
printf("%d", x);
getch();
}
Can you explain it? Why it given 56 value as output?
#include <stdio.h>
#include <conio.h>
void main()
{
int x = 070;
printf("%d", x);
getch();
}
Any integer literal (integer constant) starting with
0
is an octal representation.Quoting
C11
, chapter §6.4.4.1, Integer constantsand
and, as per chapter §7.21.6.1, for
%d
format specifier withprintf()
, (emphasis mine)Thereby, octal 70 == decimal 56.