C Expression Problems, C Logical Expression Problems

Updated on society 2024-02-08
24 answers
  1. Anonymous users2024-02-05

    Operate from right to left, -i--so calculate -i first--, the operation level is higher, so it can be written as -(i--)i--for 8, add a - sign, so -i--is 8, at this time i--after, i=7, and then -i++ is the same, can be written as -(i++) so -i++ is -7, at this time i++ becomes 8,--i, subtract 1 before execution, so --i is 7, at this time i=7, ++i is the same, add 1 before executing i, so ++i is 8, at this time i=8, then calculate i--,i--is still equal to 8, then i minus one becomes 7, i++, i++ is equal to 7, and then i++, i=8, so finally i=8, and then print it out in turn, pay attention to the operation is from right to left, but print from left to right print i,i++,i--,i,--i,-i++,i-, so the check mark result is out.

  2. Anonymous users2024-02-04

    Dizzy, this kind of question has been asked countless times, and there are so many mistakes.

    Upstairs is full of family words, can't be wrong, but definitely can't be correct.

    The GCC gave a warning obviously:

    Warning: The result of an operation on 'i' may be an undefined |A total of 6 such warnings were given.

    This multiple use of auto-increment and auto-decrement expressions in a single statement results in C language definition, in other words, each compiler can have its own understanding. Therefore, it is completely uncertain which one is calculated first and which is calculated later, and it is purely environmental.

    Changing compilers or environments is likely to result in different results.

  3. Anonymous users2024-02-03

    Well. In this case, the parameters of the function printf (those i, i++, i--) are computed from right to left.

    i, i++, i--,i,--i, -i++, i-- and, less of these expressions in the future.

    Different situations will have different results.

  4. Anonymous users2024-02-02

    Take a look at the following page, this question is related to the data stacking order of the printf function!

  5. Anonymous users2024-02-01

    The first floor is so good that it starts from the last one.

  6. Anonymous users2024-01-31

    Priority: +

    Associative law: all are left-bound combinations.

    So a||b+c&&b-c is equivalent to a ||b+c) &b-c) ) due to ||and && have the characteristics of short-circuit evaluation, so the order of calculation is:

    1.Calculate a first, if a is not 0, then the following expression does not need to be counted, and the whole expression is directly 12If a is 0, you still need to calculate the following expression, and first calculate b+c3

    If b+c is 0, then the following b-c does not need to be calculated, and the whole expression is directly 0 and not 0, and then b-c is calculated.

  7. Anonymous users2024-01-30

    This is a logical expression, there are only two possible values, 0 and 1, 1 when it is non-zero, addition and subtraction and logical operators, +- has the highest priority, followed by &&, and the lowest is ||, note that the same logical operator has different precedence. It is also important to note that parentheses are added in order of priority:

    e.g. a=3, b=4, c=5; Rule.

    a ||b + c &&b - c

    a ||b + c) &b - c))

    For each pair of logical operator operations, the resulting value is either 0 or 1, and the calculation of the entire logical expression is equivalent to decomposing it into several sub-formulas for calculation.

  8. Anonymous users2024-01-29

    Hello, && is a binocular operator, the priority is 11 and 12, respectively, +, belongs to the arithmetic operator, the priority is 4

    Therefore, the order of operations is a ||b+c) &b-c) ] i.e. (b+c) and (b-c).

    Then calculate b+c&&b-c

    Finally, a||b+c&&b-c

    I hope I am helpful to you ...

  9. Anonymous users2024-01-28

    Arithmetic operators are larger than logical operators; And &&& is greater than ||; So first b+c, b-c, then &&&, in ||

  10. Anonymous users2024-01-27

    The landlord directly looks at the priority list of symbols, and the same level is from left to right.

  11. Anonymous users2024-01-26

    The C compiler evaluates logical expressions from left to right, so c==1

  12. Anonymous users2024-01-25

    c The concept of a complete expression in a language is in addition to an operator that needs to be expressed (e.g., !).=, ==, etc.), and operands, the expression must also conform to the syntactic structure of the C language (e.g., parenthetical pairing, etc.), otherwise, the expression cannot be called a complete logical expression even if both operators and operands are present.

    Here's an example: include

    void main( )

    elseprintf("num is correct !") ;

    Where: if( (num < 0 ) num > 100 ) is a correct and complete logical expression. This expression is used to determine if the num value is less than 0, or (with ||.)Indicates that num is considered wrong if the value of num is greater than 100.

    However, if you want to express the same meaning, if( (num < 0 ) num > 100 ) The expression has not changed anywhere else, but there is a missing closing parenthesis on the right, then the expression does not conform to the syntax structure of the C language, and the C compiler cannot compile and run the program correctly, so the expression is not a complete expression.

  13. Anonymous users2024-01-24

    An expression is a sequence of operators and operands that speci es computation of a value" clearly defines an expression: that is, an expression is made up of a series of operators and operands. This is both the definition of the expression and the components of the expression.

  14. Anonymous users2024-01-23

    It's for leap

    This object is assigned a value, and the assigned value is a Boolean variable.

    You can use parentheses to make the expression explicit.

    year%4==0)

    (year%100!=0)

    (year%400==0)

    It's a surplus. Meaning:

    Variable year

    Divisible by 4 but not by 100.

    Or divisible by 400.

    The essence is to find out whether the year is a leap year. If it's a leap year, leap=true, otherwise leap returns false

  15. Anonymous users2024-01-22

    Monocular is generally a monocular operator, for example, the plus sign "+" is a double purpose, because the place where the plus sign is used is generally a few plus a few (x+y), and there are two elements of operation. A monocular operator is an element that has only one operation, for example: i++, which is a monocular operator.

  16. Anonymous users2024-01-21

    Expressions are composed of operators, constants, and variables, and are called statements with semicolons;

    The monocular operator is that there is only one quantity, like ++, etc.

  17. Anonymous users2024-01-20

    I recommend you a more comprehensive profile.

    In C, there are the following classes of expressions:

    Arithmetic expressions, relational expressions, logical expressions, assignment expressions, comma expressions.

    Monocular I think it should refer to monocular operators. Operators that require one variable for an operation are called monocular operators, and there are the following categories:

    Logical non-operator !】

    Bitwise negation operator [ ].

    The self-increasing and decrementing operator [++

    The minus operator [-].

    Type conversion operator (type)],

    Pointer operators and address operators [* and &],

    Length operator [sizeof].

  18. Anonymous users2024-01-19

    This is used in arrays, e.g. to define an array int a[3], then the elements represent: a[0], a[1], a[2].

  19. Anonymous users2024-01-18

    Conditional operator (?.): is the only trinogram operator in the C language, which detects whether the first expression is true or false, and then returns one of the other two expressions based on the result.

    Expression 1>?Expression 2>: Expression 3>

    In the operation, the first expression is first checked, and if it is true, the value of expression 2 is returned; If false, the value of expression 3 is returned.

    For example: a=(b>0)?b:-b;

    When b>0, a=b; When b is not greater than 0, a=-b; This is the conditional expression. In fact, the above means that the absolute value of b is assigned to a.

    i++ is equivalent to i = i+1;

  20. Anonymous users2024-01-17

    This is a judgment expression, for example: x>y? 0:1 When x is greater than y, the result is 0, and when x is less than y, the result is 1

    i++ is automatically added to the 1 after the i operation, and the i value after adding 1 participates in the next operation.

  21. Anonymous users2024-01-16

    Example A?b:c

    If a is true, then **b, otherwise **c, which is a shortened version of if else, is called a conditional operator, and and is a self-increasing and self-decreasing operator respectively, i represents the value of i plus one (equivalent i i 1), and i represents the value of i minus one (equivalent i i 1).

    And can not only be placed after i but also before i, (take i as an example) i means that the value of i is added after use, i means that the value of i before use is added by one, for example:

    int i=2,j=4,n;n (i) at this point n value is 2 and i value is 3).

    n=(+j)

    In this case, the n value is 5 and the j value is 5.

  22. Anonymous users2024-01-15

    Hypotheses are compared for example.

  23. Anonymous users2024-01-14

    It's called a conditional expression, and ++ is an autoincrement operator The purpose is to make it loop until the judgment condition is met.

  24. Anonymous users2024-01-13

    To do the ++ operation, you need to add 1 to this variable, which is equivalent to i=i+1

Related questions
19 answers2024-02-08

Let me try: set the time t of the q-point movement

Then s=(qn+pm)*mn2 >>>More