if and for statements

Discussion in 'C Programming' started by Paminu, Oct 4, 2005.

  1. Paminu

    Paminu Guest

    is this:
    ....
    ....
    ....
    for (i = 0; i <16; i++)
    {
    if (arg & j) a++;
    j <<= 2;
    }

    return (a & 1);
    ....
    ....
    ....

    the same as:
    for (i = 0; i <16; i++)
    {
    if (arg & j)
    {
    a++;
    }

    j <<= 2;

    }

    return (a & 1);
    Paminu, Oct 4, 2005
    #1
    1. Advertising

  2. Paminu

    Guest

    Yes
    , Oct 4, 2005
    #2
    1. Advertising

  3. wrote:

    > Yes


    It is proper Usenet etiquette to include the text you are replying to.
    To do this using Google groups, please follow the instructions below,
    penned by Keith Thompson:

    If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.

    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
    Christopher Benson-Manica, Oct 4, 2005
    #3
  4. Paminu

    Default User Guest

    wrote:

    > Yes


    Yes, what?

    --
    Please quote enough of the previous message for context. To do so from
    Google, click "show options" and use the Reply shown in the expanded
    header.
    Default User, Oct 4, 2005
    #4
  5. "Default User" <> writes:
    > wrote:
    >
    >> Yes

    >
    > Yes, what?


    Yes, Sir?

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
    Keith Thompson, Oct 4, 2005
    #5
  6. Paminu wrote:
    >
    > is this:

    [... code that differs only at ...]

    > if (arg & j) a++;


    [...and...]

    > if (arg & j)
    > {
    > a++;
    > }


    [... the same? ...]

    Yes.

    --
    +-------------------------+--------------------+-----------------------------+
    | Kenneth J. Brody | www.hvcomputer.com | |
    | kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
    +-------------------------+--------------------+-----------------------------+
    Don't e-mail me at: <mailto:>
    Kenneth Brody, Oct 5, 2005
    #6
  7. On Tue, 04 Oct 2005 21:45:44 +0200, Paminu <> wrote:

    >is this:
    >...
    >...
    >...
    >for (i = 0; i <16; i++)
    >{
    > if (arg & j) a++;
    > j <<= 2;
    >}
    >
    >return (a & 1);
    >...
    >...
    >...
    >
    >the same as:
    >for (i = 0; i <16; i++)
    >{
    > if (arg & j)
    > {
    > a++;
    > }


    Yes. If the "range" of the if is a single statement, the braces are
    optional.

    >
    > j <<= 2;
    >
    >}
    >
    >return (a & 1);



    <<Remove the del for email>>
    Barry Schwarz, Oct 5, 2005
    #7
  8. Groovy hepcat Keith Thompson was jivin' on Tue, 04 Oct 2005 20:46:43
    GMT in comp.lang.c.
    Re: if and for statements's a cool scene! Dig it!

    >"Default User" <> writes:
    >> wrote:
    >>
    >>> Yes

    >>
    >> Yes, what?

    >
    >Yes, Sir?


    Yes, Sir, three bags full, Sir. :)

    --

    Dig the even newer still, yet more improved, sig!

    http://alphalink.com.au/~phaywood/
    "Ain't I'm a dog?" - Ronny Self, Ain't I'm a Dog, written by G. Sherry & W. Walker.
    I know it's not "technically correct" English; but since when was rock & roll "technically correct"?
    Peter Shaggy Haywood, Oct 7, 2005
    #8
  9. Paminu

    pete Guest

    [ot]Re: if and for statements

    Peter Shaggy Haywood wrote:
    >
    > Groovy hepcat Keith Thompson was jivin' on Tue, 04 Oct 2005 20:46:43
    > GMT in comp.lang.c.
    > Re: if and for statements's a cool scene! Dig it!
    >
    > >"Default User" <> writes:
    > >> wrote:
    > >>
    > >>> Yes
    > >>
    > >> Yes, what?

    > >
    > >Yes, Sir?

    >
    > Yes, Sir, three bags full, Sir. :)


    One for the little boy who lives down the drain.

    "Lane" was not in my vocabulary when I learned this.

    --
    pete
    pete, Oct 7, 2005
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. spyros
    Replies:
    0
    Views:
    981
    spyros
    Jul 19, 2003
  2. Neil Zanella
    Replies:
    8
    Views:
    1,181
    mfmehdi
    Oct 20, 2006
  3. Harry George
    Replies:
    6
    Views:
    371
    Bart Nessux
    Feb 23, 2004
  4. Vince
    Replies:
    12
    Views:
    746
    Martin Gregorie
    Jan 21, 2008
  5. John Crichton
    Replies:
    6
    Views:
    261
    John Crichton
    Jul 12, 2010
Loading...

Share This Page