Lexington High School Mathematics Math Dept. Front Page  | Student Links  | Family Links 
Introduction to C++, Kevin Kelly Kelly Front Page  | C++ Course Guide | C++ Assignments | C++ Info

Assignment 17: Divisible function

due Tuesday 3/26

Write a function divisible that returns true if an integer is evenly divisible by another integer, and returns false otherwise.

For example, divisible(6,2) should return true because 6 divided by 2 divides evenly (has no remainder). On the other hand, divisible(7,2) should return false because 7 divided by 2 does not divide evenly (there is a remainder).

Also write a main program that tests the function. You may choose your own test values.




Extension

The extension is simply to make your divisible function as efficient as possible. If your divisible function involves move than one arithmetic computation, there's an easier and more efficient way to write the function. Try to find it.