1 votes 1 votes main() { int x=68; char y='D'; if (x!=y) printf("true"); else printf("false"); } the output is coming false. but why? according to me the base address is compared so answer should be true? priyanka manwani asked Aug 1, 2018 priyanka manwani 265 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes A character variable holds ASCII value rather than that character itself in C programming and ascii value of D is 68. in the loop (x!=y) means (68!=68) which is FALSE so value for comparison becomes (0) . Hence it prints FALSE arvin answered Aug 2, 2018 arvin comment Share Follow See all 4 Comments See all 4 4 Comments reply priyanka manwani commented Aug 2, 2018 reply Follow Share Yes I know this concept ....but why base address is not been compared as we do in some questions 0 votes 0 votes arvin commented Aug 2, 2018 reply Follow Share because here the variable stores the value and we are comparing value . for base address we use &X . if we declare as pointers *x than x stores address but here it stores only values. 0 votes 0 votes priyanka manwani commented Aug 2, 2018 reply Follow Share Okay I was misleading in concept... Thanks 1 votes 1 votes arvin commented Aug 2, 2018 reply Follow Share its ok no prob. :p 0 votes 0 votes Please log in or register to add a comment.