WGU C173 STUDY EXAM QUESTIONS
AND ANSWERS
What is the purpose of a variable? - ANSWER to hold value
How do you save a value to a variable? - ANSWER Use an Assignment
statement such as x=5
What is an identifier? - ANSWER A name created by a programmer for an
item like a variable or function.
What is a programming expression? - ANSWER a programming expression is a
collection of things such as variables, literals, operators, and parenthses which
evaluates to produce a value
What is a valid Identifier? - ANSWER can only include letter (a-z, A-Z),
underscore (_), and digit (0-9) combination
Must start with letter
What is a literal? - ANSWER A literal in code is an explicit value as in 2
What is an operator? - ANSWER is a symbol that performs a built-in
calculation, such as the operator + which performs addition.
What precedence rules does programming use? - ANSWER ( ) parentheses
unary -negation
, * / multiplication/ division
+ - addition/Subtraction
Left to Right
How does an integer differ from a float? - ANSWER Integer=Whole Numbers
Float=Numbers with decimals
What if you divide two integers? - ANSWER the result will be an integer no
decimal points used (use integer division)
What if you divide an integer and a float? - ANSWER (uses floating point
division)
What if you divide a non-zero floating point number by zero? - ANSWER
divide-by-zero error and the program terminates.
How do you change the type of an item? - ANSWER If either is a float the
other is converted to a float
For assignments, the right side type is changed to the left side type
integer-to-float conversion is easy: 25 becomes 25.0.
float-to-integer conversion just loses the fraction: 4.9 becomes 4.
Type casting Ex: If myIntVar is 7, then myIntVar * 1.0 changes integer 7 into
float 7.0.
What does the % operator do? - ANSWER returns the remainder of the
division of two integer operands. Ex: 23 % 10 is 3.
AND ANSWERS
What is the purpose of a variable? - ANSWER to hold value
How do you save a value to a variable? - ANSWER Use an Assignment
statement such as x=5
What is an identifier? - ANSWER A name created by a programmer for an
item like a variable or function.
What is a programming expression? - ANSWER a programming expression is a
collection of things such as variables, literals, operators, and parenthses which
evaluates to produce a value
What is a valid Identifier? - ANSWER can only include letter (a-z, A-Z),
underscore (_), and digit (0-9) combination
Must start with letter
What is a literal? - ANSWER A literal in code is an explicit value as in 2
What is an operator? - ANSWER is a symbol that performs a built-in
calculation, such as the operator + which performs addition.
What precedence rules does programming use? - ANSWER ( ) parentheses
unary -negation
, * / multiplication/ division
+ - addition/Subtraction
Left to Right
How does an integer differ from a float? - ANSWER Integer=Whole Numbers
Float=Numbers with decimals
What if you divide two integers? - ANSWER the result will be an integer no
decimal points used (use integer division)
What if you divide an integer and a float? - ANSWER (uses floating point
division)
What if you divide a non-zero floating point number by zero? - ANSWER
divide-by-zero error and the program terminates.
How do you change the type of an item? - ANSWER If either is a float the
other is converted to a float
For assignments, the right side type is changed to the left side type
integer-to-float conversion is easy: 25 becomes 25.0.
float-to-integer conversion just loses the fraction: 4.9 becomes 4.
Type casting Ex: If myIntVar is 7, then myIntVar * 1.0 changes integer 7 into
float 7.0.
What does the % operator do? - ANSWER returns the remainder of the
division of two integer operands. Ex: 23 % 10 is 3.