By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
 440,854 Members | 856 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,854 IT Pros & Developers. It's quick & easy.

# assigning expession to variable

 P: n/a Hello, Hello, When the below pgm is executed The output is "1"..How is that?How does "i" get that value "1"..Only one condition is true here(x int main() { int x=10,y=20,z=5,i; i=x
Share this Question
6 Replies

 P: n/a On 3 Sep 2003 02:31:32 -0700 in*******@yahoo.com (ambika) wrote: Hello, Hello, When the below pgm is executed The output is "1"..How is that?How does "i" get that value "1"..Only one condition is true here(x int main() { int x=10,y=20,z=5,i; i=x

 P: n/a "Pieter Droogendijk" ha scritto nel messaggio news:20030903113833.439b97e8.gi*@binky.homeunix.or g... On 3 Sep 2003 02:31:32 -0700 in*******@yahoo.com (ambika) wrote: Hello, [...] and the right assignment should be: i= (x

 P: n/a Pieter Droogendijk wrote: On 3 Sep 2003 02:31:32 -0700 in*******@yahoo.com (ambika) wrote: [snip] The < operator is evaluated left to right, and 10<20 is true, and true is represented by 1. Stare at this for a while: i = x

 P: n/a Thomas Matthews wrote: My understanding is that a boolean expression is converted to zero or nonzero (i.e. any value). Not quite. A Boolean *test* treats zero as "false" and non-zero as "true," but a Boolean *operator* always produces either zero or one, never 42. -- Er*********@sun.com Nov 13 '05 #5

 P: n/a Thomas Matthews wrote: [...] My understanding is that a boolean expression is converted to zero or nonzero (i.e. any value). Is the conversion actually to a value of 1 (one) for a boolean expression that is true? The result of a relational operator is 1 for true and 0 for false. - Kevin. Nov 13 '05 #6

 P: n/a On Wed, 03 Sep 2003 14:33:28 GMT, Thomas Matthews wrote in comp.lang.c: Pieter Droogendijk wrote: On 3 Sep 2003 02:31:32 -0700 in*******@yahoo.com (ambika) wrote: [snip] The < operator is evaluated left to right, and 10<20 is true, and true is represented by 1. Stare at this for a while: i = x

### This discussion thread is closed

Replies have been disabled for this discussion.