0 votes 0 votes what is the differernce between if (a=0) and if (a= -7) or any other non-zero number e.g what will be the out put of following program a)if ( a=0) printf(""a is zero ") else printf("a is not zero") and if we replace 0 by some +ve or -ve number then Sanjay Sharma asked Feb 17, 2017 Sanjay Sharma 2.1k views answer comment Share Follow See 1 comment See all 1 1 comment reply vishwa ratna commented Feb 18, 2017 reply Follow Share if you place any variable inside if statement like if(a) , then the body under if statement will execute till the variable is positive if a becomes zero or negative then the condition will be false. same you can infer for other numbers too, till they hold the truth value the sub codewill be executed. 0 votes 0 votes Please log in or register to add a comment.
2 votes 2 votes inside if we can have (a=0) or (a==0) there is a difference a=0 means evaluating the if expr as FALSE where as a==0 means comparing the value of a with 0 here at first (a=0) is evaluating as false so output will be A is not zero Aboveallplayer answered Feb 18, 2017 Aboveallplayer comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes if (a= 0) evaluates to false and if (a= -ve or +ve) evalutes to true. This program will print" A is not zero" Smriti012 answered Feb 18, 2017 Smriti012 comment Share Follow See all 2 Comments See all 2 2 Comments reply Jitendra13 commented Dec 26, 2019 reply Follow Share hi, can you explain if(a = -7) is evaluated as true 0 votes 0 votes teja1521 commented Mar 11 reply Follow Share -7 is assigned to a and then here a is an expression in if condition and it holds -7 which is a non zero. so, the condition will be true. 0 votes 0 votes Please log in or register to add a comment.