about | help
CodingBat code practice

Code Help and Videos >

 Introduction to Mod Code

Video

This page introduces how the "mod" % operator works in Java and other languages along with a few live practice code problems.

Mod % Operator

You're familiar with the 4 arithmetic operations + - * /. The % modulus operator is an additional arithmetic operation: basically the remainder left over after division. For example, what is 73 % 10? The simplest way to think about it is, keep subtracting 10's from 73 until there's less than 10 left (3 in this case).

Key Features of Mod

Practice Mod Problems

or35 H   specialEleven  old35  more20  less20  nearTen 

MakeBricks Problem

More difficult problems that also use mod: makeBricks  makeChocolate 

(in python: make_bricks  make_chocolate )

See also Introduction to MakeBricks

CodingBat.com code practice. Copyright 2013 Nick Parlante.