C7: Operators and Expression Flashcards

1
Q

What is an expression?

A

An expression is a formula that describes how to compute a value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does it mean to evaluate an expression?

A

Evaluating an expression means computing the value of an expression

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Give an example of a simple expression.

A

A constant (14) or a variable (a).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Is assignment an operator or a statement in C?

A

In C, assignment is an operator. The assignment (right to left) then evaluates to a value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a sequence point?

A

“any point in a computer program’s
execution at which it is guaranteed that all side effects
of previous evaluations will have been performed, and
no side effects from subsequent evaluations have yet
been performed.” (Wikipedia)”
OR
a point in the evaluation of a function when all side effects of operators so far encountered are guaranteed to be complete

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the use of sequence point?

A

Sequence points determine when the side effects of an expression are determined and sequence point rules make some expressions undefined.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are some defined sequence points?

A

 Between evaluation of function designator and actual
arguments in a function call and the actual call
 Between evaluation of operands of &&, ||, comma
operator
 Between evaluation of operands of ? : operator
 At the end of a full declarator
 Between evaluation of full expressions
 Immediately before a library function returns
 Immediately before and after each call to a comparison
function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is an expression statement?

A

An expression statement is simply an expression followed by a semicolon. (An expression is a formula that describes how to compute a value.) This is because expressions can be combined into more complex expressions using operators and assignment is an operator in C. That means that a statement (with assignment) is an expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the general difference between expressions and statements and how is C special in that regard?

A

The general difference between expressions and statements is that expressions compute a value and statements have a side effect. In C, assignment operators create expressions so expression have a side effect in these so-called “expression statements”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly