Practice Integer in CS Thinking

Use these practice problems to test your method after reviewing the concept explanation and worked examples.

Quick Recap

A data type that represents whole numbers (positive, negative, or zero) without decimal points. Integers are stored exactly in memory and support arithmetic operations like addition, subtraction, multiplication, and integer division.

Integers are counting numbers in code โ€” things you can count without fractions: age, score, quantity, index.

Example 1

easy
What is the result of integer division 17 \div 5 and 17 \mod 5? Explain the difference from regular division.

Example 2

medium
A program stores a student's age as an integer. Why would an integer be more appropriate than a floating-point number for age in years?

Example 3

easy
What are the results of: (a) 25 MOD 7, (b) 100 DIV 3, (c) 8 MOD 2?

Example 4

medium
A vending machine program stores the price as 175 (meaning $1.75 in cents). A customer inserts 200 cents. Using only integer arithmetic (DIV for integer division, MOD for remainder), calculate the change in dollars and remaining cents.