Chapter 7 - Expressions and Assignment Statements

0.0(0)
Studied by 4 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/49

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:15 PM on 5/20/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

50 Terms

1
New cards

Expressions

___ are the fundamental means of specifying computations in a programming language.

2
New cards

assignment statements

Essence of imperative languages is dominant role of ___.

3
New cards

Arithmetic evaluation

___ was one of the motivations for the development of the first programming languages.

4
New cards

mathematics

Most of the characteristics of arithmetic expressions in programming languages were inherited from conventions that had evolved in ___.

5
New cards

unary,

binary,

ternary

An operator can be ___, meaning it has a single operand, ___, meaning it has two operands, or ___, meaning it has three operands.

6
New cards

arithmetic computation

The purpose of an arithmetic expression is to specify an ___.

7
New cards

1. Precedence

2. Associativity

3. Parenthesis

4. Expressions in Lisp

5. Conditional Expressions

Operator Evaluation Order (5 in order)

8
New cards

precedence

The operator ___ rules for expression evaluation define the order in which the operators of different precedence levels are evaluated.

9
New cards

identity operator

Unary addition (+) is called the ___ because it usually has no associated operation and thus has no effect on its operand.

10
New cards

unary minus

In Java and C#, ___ also causes the implicit conversion of short and byte operands to int type.

11
New cards

associativity

The operator ___ rules for expression evaluation define the order in which adjacent operators with the same precedence level are evaluated. An operator can be either left or right associative.

12
New cards

Fortran

- Typical associativity rules:

Left to right, except **, which is right to left

Sometimes unary operators associate right to left such as ___

13
New cards

Fortran

Associativity

A * B * C is seen in what language? ___

14
New cards

Ada

Associativity

(A * B) * C is seen in what language? ___

15
New cards

APL

___ is different; all operators have equal precedence and all operators associate right to left.

A x B + C

// A = 3, B = 4, C = 5 -> 27

16
New cards

parentheses

Programmers can alter the precedence and associativity rules by placing ___ in expressions.

17
New cards

subprograms

Lisp:

All arithmetic and logic operations are by explicitly called ___

18
New cards

If-then-else

These are used to perform conditonal expression assignment

19
New cards

Variables

Operand evaluation order:

___ fetch the value form memory

20
New cards

Constants

Operand evaluation order:

___ sometimes a fetch from memory; sometimes the constant in the machine language instruction and not require a memory fetch.

21
New cards

Parenthesized expression

Operand evaluation order:

___ evaluate all operands and operators first

22
New cards

functional side effect

A side effect of a function, called a ___, occurs when the function changes either one of its parameters or a global variable.

23
New cards

- Write the language definition to disallow functional side effects

- Write the language definition to demand that operand evaluation order be fixed

Two possible solutions to the functional side effects problem:

24
New cards

Java

____ guarantees that operands are evaluated in left-to-right order, eliminating this problem

25
New cards

operator overloading

The use of an operator for more than one purpose is ____.

26
New cards

Java

___ uses + for addition and for string catenation

27
New cards

C++

C#

F#

___, ___, and ___ allow user-defined overloaded operators

- When sensibly used, such operators can be an aid to readability (avoid method calls, expressions appear natural)

- Potential problems:

Users can define nonsense operations

Readability may suffer, even when the operators make sense

28
New cards

narrowing conversion

A ___ is one that converts an object to a type that cannot include all of the values of the original type e.g., double to float.

29
New cards

widening conversion

A ___ is one in which an object is converted to a type that can include at least approximations to all of the values of the original type e.g., int to float.

30
New cards

mixed-mode

A ___ expression is one that has operands of different types.

31
New cards

coercion

A ___ is an implicit type conversion

32
New cards

ML

F#

In ___ and ___, there are no coercions in expressions

33
New cards

casts

In the C-based languages, explicit type conversions are called ___

34
New cards

Java

In ___, to specify a cast, the desired type is placed in parentheses just before the expression to be converted, as in

35
New cards

relational operator

A ___: an operator that compares the values of its two operands

36
New cards

Boolean

The value of a relational expression is ___, unless it is not a type included in the language

37
New cards

JavaScript,

PHP

___ and ___ have two additional relational operator, === and !==

- Similar to their cousins, == and !=, except that they do not coerce their operands

38
New cards

C99

Versions of C prior to ___ have no Boolean type; it uses int type with 0 for false and nonzero for true.

39
New cards

short-circuit evaluation

A ___ of an expression is one in which the result is determined without evaluating all of the operands and/or operators.

40
New cards

==

The C-based languages use ____ as the equality relational operator to avoid confusion with their assignment operator

41
New cards

=

The operator symbol for assignment:

____ Fortran, Basic, PL/I, C, C++, Java

42
New cards

:=

The operator symbol for assignment:

___ ALGOL, Pascal, Ada

43
New cards

compound assignment operator

A ___ is a shorthand method of specifying a commonly needed form of assignment

44
New cards

unary operator

A ___ is called so because it operates on only one operand. The term "unary" comes from the Latin word "unus," meaning one. In programming, unary operators take a single value or operand, modify it, and return a result.

45
New cards

Increment Operator (++)

Decrement Operator (--)

In C-based languages, there are two special unary operators used for incrementing and decrementing a variable's value, which can be combined with assignment operations, these are?

46
New cards

Assignment as an Expression

This design treats the assignment operator much like any other binary operator, except that it has the side effect of changing its left operand.

47
New cards

difficult to read and understand.

Assignment as an Expression

Disadvantage: another kind of expression side effect which leads to expressions that are ___

48
New cards

Perl

Ruby

Lua

___, ___, and ___ provide multiple-target multiple-source assignments

49
New cards

values

Identifiers in functional languages are only names of ___

50
New cards

mixed-mode assignment

A ___ occurs when the value being assigned to a variable is of a different type than the variable itself. In this case, the language may automatically convert or coerce the value to the correct type before the assignment is made.