statements in C

This is a discussion on statements in C within the C Programming forums, part of the General Programming Boards category; There are expression;selection;jump;iteration;label;block statements. Is follwoing expression statement? int a;...

  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    61

    statements in C

    There are expression;selection;jump;iteration;label;block statements. Is follwoing expression statement?

    int a;

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    Nope, it isn't a statement.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    61
    then what int a; is?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    A declaration of a variable.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    61
    I think int a; is a statement in C. Still I am not getting the satishfactory answer

  6. #6
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,761
    >> I think int a; is a statement in C. Still I am not getting the satishfactory answer
    Well, the answer you got is the correct one.

    Statements in C are expressions of the form
    left = right;

    Sorry, it's anticlimactic.

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Well, if you want a concise explanation of all the lexical definitions in C, look at this page:
    http://www.jaggersoft.com/csharp_grammar.html

    Ok, so it's for C-sharp, but it's so similar that I think we can take it as "the same" for this purpose.

    According to that, the line you show is a declaration statement.

    But declaration statement isn't in your list, so I guess that's not a valid answer to your question.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Quote Originally Posted by citizen View Post
    Statements in C are expressions of the form
    left = right;
    Statements must be expressions?

  9. #9
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,806
    Quote Originally Posted by forumuser View Post
    I think int a; is a statement in C. Still I am not getting the satishfactory answer
    http://en.wikipedia.org/wiki/Stateme...programming%29
    Many languages (eg, C) make a distinction between statements and definitions, with a statement only containing executable code and a definition declaring an identifier.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  10. #10
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,270
    Quote Originally Posted by forumuser View Post
    I think int a; is a statement in C. Still I am not getting the satishfactory answer
    So you've already made up your mind what the answer is, came here for validation, got corrected, and now you're dissatisfied? Funny.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Unknown memory leak with linked lists...
    By RaDeuX in forum C Programming
    Replies: 6
    Last Post: 12-07-2008, 04:09 AM
  2. newbie question - if statements without conditions
    By c_h in forum C++ Programming
    Replies: 2
    Last Post: 07-18-2008, 11:42 AM
  3. C++ If Statements Help
    By moporho in forum C++ Programming
    Replies: 19
    Last Post: 01-18-2008, 08:40 AM
  4. Efficiency of case statements
    By Yasir_Malik in forum C Programming
    Replies: 26
    Last Post: 05-23-2006, 12:36 PM
  5. Switch statements for strings
    By cxs00u in forum C++ Programming
    Replies: 5
    Last Post: 04-17-2002, 04:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21