+ 6
How 04 is a character in this without single quotes
10 odpowiedzi
+ 1
a character literal is nothing more than a UTF-16 encoded integer. instead of using the literal character you are directly assigning the corresponding numeric encoding
+ 6
How is 04 a character when it has no single quotes?
char accepts either a character with single quotes or a direct ASCII value.
Any value leading with 0 is octal number(base 0-7)
eg: 04, 065 etc
char f = 04;
// if we convert octal number 04 to decimal value we will have 4
// Now f = 4 and if you check from the ascii value number 4 is use for "end of transmission" sign and hence we empty blank output.
One more example:
Suppose you have,
char f = 065;
065 is octal and is converted to decimal by compiler and hence we have 53(decimal), again check in the ascii table you will find that the value 53 is '5' and hence we will get an output of 5.
+ 2
rkk Thanks
+ 2
rkk what I am getting error on inputing 08?
+ 2
Atul because octal is base (0-7)
so 8 is not in its range
+ 1
Ciro Pellegrino can u please elaborate ur explanation?
+ 1
rkk Do 04 is the only numbers for the end of transmission or the numbers from 0-7?
+ 1
Atul
octal 04 when converted to decimal is 4 and if you check in ascii values table you will see that 4 is used for "end of transmission" and that this is the reason we are getting an empty output.
Yes, there's only one number 4 for "end of transmission".
I think you are asking this question because for some other values too you will get an empty output and that's because some weird ascii value will print empty blank output.
Check this ascii value table for:
https://images.app.goo.gl/NjUAm1jRpuWLvfcM9
0
Ciro Pellegrino thank u
0
rkk thank you