#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Posts
    20
    Rep Power
    0

    Expressions in c


    an expression is a combination of operators and operands?
    Does ANSI have a list of valid operands?
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,997
    Rep Power
    9397
    A valid operand is just another an expression, so pretty much anything works: constants, variables, pointers, assignments, function calls...
  4. #3
  5. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1802
    An operand is simply an expression. What determines validity of an operand is its type (int, float, double, etc or a pointer-type) and whether it is defined for the particular operator.

    Perhaps you confused operand and operator, and meant a "list of operators"? The answer to that question is however easily available elsewhere and not worth repeating here.

    The operators available in a language (you did not specify C, C++ Objective-C or C# - all covered by this forum), are defined by the language not ANSI. ANSI is a US national standard's body, not a programming language. ANSI did at one time define the standard for C, but that is now the responsibility of the ISO. ANSI C refers to the pre-ISO standard commonly referred to as C89. ISO C90 is identical in language terms, both are superseded by C99 and C11 (the numbering scheme shows we have learned nothing from the Y2K bug ;))
  6. #4
  7. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,109
    Rep Power
    1802
    Originally Posted by requinix
    A valid operand is just another an expression, so pretty much anything works: constants, variables, pointers, assignments, function calls...
    ...Although pointers are valid for a smaller subset of operators that other types.
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,145
    Rep Power
    2222
    Originally Posted by web9452
    an expression is a combination of operators and operands?
    Does ANSI have a list of valid operands?
    Just simply refer to the syntax.

    Eg, The syntax of C in Backus-Naur Form. Or you could Google for more examples.

    You might want to start with this and start expanding:
    Code:
    <expression> ::= <assignment-expression>
                   | <expression> , <assignment-expression>

IMN logo majestic logo threadwatch logo seochat tools logo