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 / vignesh1988i

the value is 0 so this will go to 3.. the value of b=3
a) b=3... since we are not comparing the value os a's...
this is an assignment statement.... so a itself is 0, which
is an false condition.... so it moves to 3

b) the value of b=2... since -1 ia an non zero value... the
whole term wil become true....

c) b=2... same reson as above

actually the above conditional operater statement must be
full y enclosed witin braces.... then only we should assign
to a variable....

Is This Answer Correct ?    4 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are conditional operators in C?

621


An integer that indentifies the position of a data item in a sequence of data items a) value b) number c) index d) all of the above

645


Write a program to implement queue.

664


how can f be used for both float and double arguments in printf? Are not they different types?

606


What is difference between structure and union in c programming?

566






How do I use void main?

629


What does it mean when the linker says that _end is undefined?

625


List the difference between a "copy constructor" and a "assignment operator"?

578


What does 2n 4c mean?

713


write a program to rearrange the array such way that all even elements should come first and next come odd

1759


write a program to input 10 strings and compare without using strcmp() function. If the character of one string matches with the characters of another string , sort them and make it a single string ??? example:- str1="Aakash" st2="Himanshu" str="Uday" output:- Aakashimanshuday (please post the answer as quickly as possible)

1625


Explain what is the difference between null and nul?

650


What is scope and lifetime of a variable in c?

572


how we can make 3d venturing graphics on outer interface

4000


What is graph in c?

583