EXPRESSION WEEK 2 Flashcards
(38 cards)
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.
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 are the forms of relational expressions listed in C language, and what do they mean?
Answer: Relational expressions in the C language take one of six forms: operand == operand (operands are equal), operand > operand (left is greater than the right), operand >= operand (left is greater than or equal to the right), operand < operand (left is less than the right), operand <= operand (left is less than or equal to the right), and operand != operand (left is not equal to the right).
Question: What types of operands are allowed in relational expressions in C language?
.
Answer: The operands may be integral types or floating-point types
Question: What are logical expressions in the C language, and how does it interpret the values true and false?
Answer: Logical expressions in the C language are used to evaluate a condition. The C language does not have reserved words for true or false. It interprets the value 0 as false and any other value as true.
Question: What are the three logical operators supported by the C language, and what do they mean?
Answer: The C language supports three logical operators: operand && operand (both operands are true), operand || operand (one of the operands is true), and ! operand (the operand is not true).
Question: What is the data type of a value yielded by a logical expression?
Answer: The value of a logical expression is of type int.
What is deMorgan’s Law in C programming?
Answer: deMorgan’s Law is a rule that allows the conversion of compound conditions in logical expressions. It states that the opposite of a compound condition is the compound condition with all sub-conditions reversed, all &&’s changed to ||’s and all ||’s to &&’s.
What is an example of applying deMorgan’s Law in C programming?
Answer: One example of applying deMorgan’s Law is in defining an adult in C as “!child && !senior”, which is logically equivalent to the expression “!(child || senior)”.
What are shorthand assignments in C programming?
Answer: Shorthand assignments are operators that combine an arithmetic expression with an assignment expression in C programming. They store the result of the arithmetic expression in the left operand.