Last active
November 1, 2021 09:35
-
-
Save trashvin/d12e1885ec8eec7acba9da6d8d66a3be to your computer and use it in GitHub Desktop.
Revisions
-
trashvin renamed this gist
Nov 1, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
trashvin renamed this gist
Nov 1, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
trashvin created this gist
Nov 1, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ #include <iostream> #include <math.h> using namespace std; bool isDivisible(double number, double divisor); int main() { // generate 20 random numbers and checkif div by 10 for (int i = 0; i < 20; i++) { double number = rand() % 1000; if (isDivisible(number, 10)) { cout << "the number " << number << " is divisible by 10" << endl; } else { cout << "the number " << number << " is NOT divisible by 10" << endl; } } return 0; } bool isDivisible(double number, double divisor) { double floatPart, integerPart = 0; double quotient = number / divisor; if (modf(quotient, &integerPart) == 0) return true; else return false; }