c = (a) ? b : d++; and c = (a==c) ? b : d++;
or they are completely different?
{a,b,c,d} are random numbers.
I know what the second one means i just cant understand if the first one is any different.
c = (a) ? b : d++; and c = (a==c) ? b : d++;
or they are completely different?
{a,b,c,d} are random numbers.
I know what the second one means i just cant understand if the first one is any different.
Do you understand what the ternary operator does? Also, remember that any non-zero value is considered true in C. Maybe it would be easier if you converted these into their if-else equivalents and then tried to answer it.
They're different. The condition for the first one only checks if a is anything except 0, and the second one checks if a equals c.
If you understand what you're doing, you're not learning anything.
First of all thanx for the reply.
Yeap i know what the ternary conditional operator does.
The thing is that i cant figure out what the condition on the first one c = (a) ? b : d++; is.
How can a plain (a) be any condition?Is it a shortcut for (c==a)?
Last,i cant convert it into if-else equivalents since i i dont know how and im pretty new working with C language(noob actually).
Anything non-zero is considered true. So:Means:Code:if( a )Quzah.Code:if( a != 0 )
Hope is the first step on the road to disappointment.