+ 1

Why this output is "1"?? please explain....

#include<stdio.h> int main() { int x=5, y=10, z=10; x=y==z; printf("%d", x); return 0; }

20th Apr 2017, 1:08 PM
Tanvir Ahmed Nabil
Tanvir Ahmed Nabil - avatar
6 ответов
+ 2
because you are assigning an expression so y == z its true so true == 1
20th Apr 2017, 1:14 PM
Alejandro Serrato
Alejandro Serrato - avatar
+ 1
#include<stdio.h> int main() { int x,y=10; char z='a'; x=y+z; printf("%d", x); return 0; } Output??
20th Apr 2017, 1:24 PM
Tanvir Ahmed Nabil
Tanvir Ahmed Nabil - avatar
+ 1
it gives you 107 because it is taking the ASCII of 'a' that is 97 so you got x = 10 + 97 = 107
20th Apr 2017, 1:35 PM
Alejandro Serrato
Alejandro Serrato - avatar
0
thank you.
20th Apr 2017, 1:18 PM
Tanvir Ahmed Nabil
Tanvir Ahmed Nabil - avatar
0
is 'single_quotation' meaning of ASCII number? does it ('a') has another meaning??
20th Apr 2017, 2:46 PM
Tanvir Ahmed Nabil
Tanvir Ahmed Nabil - avatar
0
actually 'a' is a character but as the variable that gets the result is of type int you can't concatenate 10+'a' that's​ why it takes the ASCII number
20th Apr 2017, 2:53 PM
Alejandro Serrato
Alejandro Serrato - avatar