Advertisement

Is the modulus operator (%) useful?

Is the modulus operator (%) useful? I observe a lot of new programmers, and I've noticed that they tend to avoid the modulus operator (%), even after they learn about it.

This video provides a few useful scenarios when you might want to start using it in your programs, specifically when trying to determine even division and manage circular buffers.

The examples are in C, but the use of the operator applies easily to C++, java, python, ruby, and most other imperative languages.

About me: I'm a computer scientist, researcher, teacher, and Internet of Things enthusiast. I teach systems and networking courses at Clemson University. I lead the PERSIST research lab.

More about me and what I do:




To Support the Channel:
+ like, subscribe, spread the word
+ contribute via Patreon --- [

Source code is also available to Patreon supporters. --- [
Note: I haven't posted ALL of the code from ALL of my videos yet. The site contains code from my recent tutorials (I wasn't quite as organized in the pre-2019 past). I will add examples from older videos as I dig them up.

modulus,mod,modulo,c language,c++,python,ruby,java,circular buffer,circular array,wrap around,

Post a Comment

0 Comments