+ 3

Whats the reason behind this output?

My sister was typing this and found this output, then she called me , and asked "What is this in the output?" Actually she missed out the quotes while declaring the character. But even though the output should not be this. https://code.sololearn.com/cMf45JfPsXkx/?ref=app

11th Feb 2018, 3:11 AM
AnonySharma
AnonySharma - avatar
10 Respostas
+ 8
This is a random garbage value that has been assigned to a and b. Without the quotes, a gets a's value, which was not assigned yet. and results in a garbage value. Thus you get the weird output. Similar things happen with b, but since b is a char, it gets restrained to an ASCII value...
11th Feb 2018, 3:15 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 4
Before initializing i.e. allocating a value to a variable it has its own value which is called as garbage value which is happing with int a. And as I think b is pointing to null. So to get proper output replace int a = with any number char b = 'any character'
11th Feb 2018, 3:18 AM
Hrishikesh Kulkarni
Hrishikesh Kulkarni - avatar
+ 4
I'm not sure that b is having garbage value as it displays nothing . So , either it's value is null or it's pointing nowhere that means no value is there . https://stackoverflow.com/questions/25573435/what-is-the-default-value-of-char-in-c
11th Feb 2018, 3:29 AM
Hrishikesh Kulkarni
Hrishikesh Kulkarni - avatar
+ 3
I'm not sure that b is having garbage value as it displays nothing . So , either it's value is null or it's pointing nowhere that means no value is assigned to b. https://stackoverflow.com/questions/25573435/what-is-the-default-value-of-char-in-c
11th Feb 2018, 3:29 AM
Hrishikesh Kulkarni
Hrishikesh Kulkarni - avatar
+ 3
ooh thanks :-) the StackOverflow's link helped
11th Feb 2018, 3:35 AM
AnonySharma
AnonySharma - avatar
+ 2
no, b doesn't shows anything, that's what I'm curious about. you can try removing the statements consisting a;
11th Feb 2018, 3:19 AM
AnonySharma
AnonySharma - avatar
+ 2
@Hrishikesh but why doesn't b stored any garbage value
11th Feb 2018, 3:21 AM
AnonySharma
AnonySharma - avatar
+ 2
Oh, thanks @Ace
11th Feb 2018, 3:42 AM
AnonySharma
AnonySharma - avatar
+ 1
Can anyone of you, answer this question..? https://www.sololearn.com/Discuss/1063293/?ref=app Thanks in advance :)
11th Feb 2018, 3:47 AM
AnonySharma
AnonySharma - avatar