Re: How printf() works???????



On 7 Mar, 09:10, "Robbie Hatley" <lonew...@xxxxxxxx> wrote:
"Richard" <de...@xxxxxxxxx> wrote:
Richard Heathfield <r...@xxxxxxxxxxxxxxx> writes:

sant.ta...@xxxxxxxxx said:

Hello,

I would appreciate some comments about the piece of code given below
and explanation about the result of this specified code.

int x = 20;

printf("%d %d %d",x < 30, x = 40; x > 10);

The output of these code will be :: 0 40 1

Well, it might be, once you wrap a program around it and fix the syntax
error (a semicolon instead of a comma). First, I'll explain why you might
get that output, and then I'll explain why you might not.

x < 30 is a relational expression, and all expressions have values.
Relational expressions have the value 0 if they're false, and 1 if they're
true. So x < 30 will evaluate to 0 if x is less than 30, and 1
otherwise.

It won't actually.

How do you figure?  It does in standard C.  If it doesn't for you,
then your compiler is broken and you should get a better one.


Richard Heathfield made a typo. He meant "So x < 30 will evaluate to
*1* if x
is less than 30, and *0* otherwise."



--
Nick Keighley



.



Relevant Pages

  • Re: American semicolons
    ... claim that Americans 'only use ";" to separate two things that would ... semicolon can be a strong comma as well as weak period. ...
    (alt.usage.english)
  • Re: Macro crashing on different computer
    ... >ConsecutiveDelimiter, Tab, Semicolon, Comma, Space, ... >FieldInfo, DecimalSeparator, ThousandsSeparator) ...
    (microsoft.public.excel.programming)
  • Re: Cannot multiselect programmatically?
    ... I am just using the semicolon to separate the items in the list (and to end ... > comma-delimitd list but the comma is not part of the list value. ... >> items in the listbox already selected by default when the form is loaded. ... How do I programmatically select multiple items in the list? ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Find and Replace with Wildcards
    ... This starts with a semicolon, finds everything but a semicolon and comma up ... A peer in "peer to peer" support ... > I turned wildcards on and did a find and replace using the following> values for starters: ...
    (microsoft.public.word.docmanagement)
  • Re: comma operator
    ... may have returned has been discarded by the comma; ... and the semicolon at the end discards the value ... extra gyrations to make the second function ...
    (comp.lang.c)