a=0;
b=(a=0)?2:3;
a) What will be the value of b? why
b) If in 1st stmt a=0 is replaced by -1, b=?
c) If in second stmt a=0 is replaced by -1, b=?

Answer Posted / ashwin kumar

3 is the answer

2nd guy says we can't use "=" it's wroung we can use it in
this condition .


expl:

1st it will check condition part , condition part will
return false as, ANY VALUE OTHER THAN ZERO TAKEN AS TRUE IN
C LANGUAGE , here we are assiging zero to 'a' which give
false.


from basic of above contion , it condition return false it
will execute or return 2nd statement, i.e 3

so out put will be 3

Is This Answer Correct ?    7 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What was noalias and what ever happened to it?

590


pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)

2197


Is swift based on c?

638


What is the meaning of c in c language?

593


How can variables be characterized?

1647






Is r written in c?

722


What is getch c?

847


Why do we write return 0 in c?

549


What is pointer to pointer in c?

632


What is difference between structure and union in c?

544


How do you define a string?

649


Hai sir, I had planned to write the NIC scientific engineer exam , plz post the sample question......

1740


What is the purpose of main( ) in c language?

616


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

744


What is advantage of pointer in c?

687