EXPRESSION WEEK 2 Flashcards
Question: What is the purpose of operators in programming languages?
Answer: Operators in programming languages are used to combine variables and constants into expressions for transforming existing data into new data.
Question: What types of operands can be used with operators in programming languages?
Answer: The operands that can be used with operators in programming languages include variables, constants, or other expressions
Question: What types of operators are supported in the C language?
Question: What is the data type of a value yielded by a relational expression?
Answer: The value of a relational expression is of type int.
Question: What happens when operands of different types are used in an expression?
Answer: This chapter describes what happens when operands of different types are used in an expression, including how to change the type of an operand.
Question: What are the hardware components that evaluate expressions?
Answer: The hardware components that evaluate expressions are the ALU and FPA inside the CPU.
Question: What expressions can the ALU process on integer types?
Answer: The ALU can process arithmetic, relational, and logical expressions on integer types.
Question: What expressions can the FPA process on floating-point types?
Answer: The FPA can process arithmetic, relational, and logical expressions on floating-point types.
Question: What are the types of operands used in arithmetic expressions?
Answer: Arithmetic expressions consist of integral operands for processing by the ALU and floating-point operands for processing by the FPA.
Question: How many binary and unary arithmetic operations does the C language support on integral operands?
Answer: The C language supports 5 binary and 2 unary arithmetic operations on integral (int and char) operands.
Question: What are the binary arithmetic operations on integers and what are their meanings?
Answer: The binary arithmetic operations on integers are addition, subtraction, multiplication, division and remaindering. Their meanings are as follows:
operand + operand: add the operands
operand - operand: subtract the right from the left operand
operand * operand: multiply the operands
operand / operand: divide the left by the right operand. If the division is not exact, the operation discards the remainder and the expression evaluates to the truncated integer result.
operand % operand: remainder of the division of left by right. The expression evaluates to the remainder alone.
Question: What are the unary arithmetic operations supported by the C language?
Answer: The unary arithmetic operations supported by the C language are identity and negation, which are represented by the expressions + operand and - operand.
Question: What are the binary arithmetic operations on floating-point operands in C?
Answer: The binary arithmetic operations on floating-point operands in C are addition, subtraction, multiplication, and division, which are represented by the expressions operand + operand, operand - operand, operand * operand, and operand / operand.
Question: Does the division operator (/) for floating-point operands in C evaluate to a whole number or a floating-point result?
Answer: The division operator (/) for floating-point operands in C evaluates to a floating-point result.
Question: What is the purpose of the plus operator in C arithmetic expressions involving unary operations?
.
Answer: The plus operator in C arithmetic expressions involving unary operations is present for language symmetry and leaves the value unchanged
Question: What are relational expressions in C language, and how many relational operations does it support?
Answer: Relational expressions in the C language evaluate a condition and compare two values, yielding 1 if the condition is true and 0 if the condition is false. The C language supports 6 relational operations.