CSE 1321 TEST PAPER EXAMS 2026/2027 QUESTIONS AND
SOLUTIONS RATED A+
✔✔An algorithm is just - ✔✔a set of instructions
✔✔Abstraction is just - ✔✔the level of detail
✔✔Skeleton programs: - ✔✔-Are the smallest program you can write
-Are the minimal amount of code that compiles
-Do NOTHING
-Define the entry/starting point of the program
✔✔A variable: - ✔✔-Is a chunk of the computer's memory
-Can hold a value
-Is of a particular "type"
Integer
Floating point number
Character
String - which is just text
✔✔Variables: Usually, it's two steps: - ✔✔-"Declare" the variable - tell the computer
what it is (do this only once)
-Assign values to the variable
✔✔Basic Operators - ✔✔Math Operators
Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)
✔✔An ------ is a combination of one or more operators and operands - ✔✔expression
✔✔It has both a data type and a value that results from the expression evaluation -
✔✔expression
✔✔Operands may be: - ✔✔- literals
-constants
-variables
✔✔Arithmetic Operators - ✔✔+ addition
- subtraction
* multiplication
/ division
% modulus (say what?)
, ✔✔When dividing two integer values: - ✔✔- the quotient is an integer
-the remainder is truncated (discarded)
✔✔To get the ------, use the modulus operator with the same operands - ✔✔remainder
✔✔Operator Precedence - ✔✔Left-to-right operations
- multiplication, division and modulus
- addition and subtraction (example 3 + 3)
- string concatenation ("Hello, " + "world!")
Right-to-left operations
- unary plus and unary minus (example, +1 or -1)
- assignment
✔✔Variable = expression; - ✔✔1) the expression on the right side of the = operator is
evaluated Expression has data type and value
2) the result is stored in the variable on the left if the types are compatible (overwriting
the original value)
✔✔Shortcut Operators - ✔✔++ increment by 1
-- decrement by 1
+= a += 3; a = a + 3;
-= a -=10; a= a-10;
*= a*=4; a= a*4;
/= a/=7; a= a / 7;
%= a%=10; a= a % 10;
✔✔Two Types of Data Conversion - ✔✔-Widening conversion (promotion)
-Narrowing conversion (demotion)
✔✔Widening conversion (promotion) - ✔✔-safe, do not lose data
-goes to a "wider" (more bits) data type
-may lose precision (long to float)
✔✔Narrowing conversion (demotion) - ✔✔-may lose data
-may lose precision
-should be avoided
-compiler error unless specific cast done
✔✔Conversion Techniques - ✔✔- Assignment conversion
Example: assign an int to a long
-Promotion
SOLUTIONS RATED A+
✔✔An algorithm is just - ✔✔a set of instructions
✔✔Abstraction is just - ✔✔the level of detail
✔✔Skeleton programs: - ✔✔-Are the smallest program you can write
-Are the minimal amount of code that compiles
-Do NOTHING
-Define the entry/starting point of the program
✔✔A variable: - ✔✔-Is a chunk of the computer's memory
-Can hold a value
-Is of a particular "type"
Integer
Floating point number
Character
String - which is just text
✔✔Variables: Usually, it's two steps: - ✔✔-"Declare" the variable - tell the computer
what it is (do this only once)
-Assign values to the variable
✔✔Basic Operators - ✔✔Math Operators
Addition (+)
Subtraction (-)
Multiplication (*)
Division (/)
✔✔An ------ is a combination of one or more operators and operands - ✔✔expression
✔✔It has both a data type and a value that results from the expression evaluation -
✔✔expression
✔✔Operands may be: - ✔✔- literals
-constants
-variables
✔✔Arithmetic Operators - ✔✔+ addition
- subtraction
* multiplication
/ division
% modulus (say what?)
, ✔✔When dividing two integer values: - ✔✔- the quotient is an integer
-the remainder is truncated (discarded)
✔✔To get the ------, use the modulus operator with the same operands - ✔✔remainder
✔✔Operator Precedence - ✔✔Left-to-right operations
- multiplication, division and modulus
- addition and subtraction (example 3 + 3)
- string concatenation ("Hello, " + "world!")
Right-to-left operations
- unary plus and unary minus (example, +1 or -1)
- assignment
✔✔Variable = expression; - ✔✔1) the expression on the right side of the = operator is
evaluated Expression has data type and value
2) the result is stored in the variable on the left if the types are compatible (overwriting
the original value)
✔✔Shortcut Operators - ✔✔++ increment by 1
-- decrement by 1
+= a += 3; a = a + 3;
-= a -=10; a= a-10;
*= a*=4; a= a*4;
/= a/=7; a= a / 7;
%= a%=10; a= a % 10;
✔✔Two Types of Data Conversion - ✔✔-Widening conversion (promotion)
-Narrowing conversion (demotion)
✔✔Widening conversion (promotion) - ✔✔-safe, do not lose data
-goes to a "wider" (more bits) data type
-may lose precision (long to float)
✔✔Narrowing conversion (demotion) - ✔✔-may lose data
-may lose precision
-should be avoided
-compiler error unless specific cast done
✔✔Conversion Techniques - ✔✔- Assignment conversion
Example: assign an int to a long
-Promotion