Are both these codes the same
char ch = \'a\';
printf(\"%d\", ch);
Will it print a garbage value?
I am confused about this
%d prints an integer: it will print the ascii representation of your character. What you need is %c:
printf("%c", ch);
printf("%d", '\0'); prints the ascii representation of '\0', which is 0 (by escaping 0 you tell the compiler to use the ascii value 0.
printf("%d", sizeof('\n')); prints 4 because a character literal is an int, in C, and not a char.