Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misunderstanding of Ex. 14.43 #45

Open
icelandicinquisition opened this issue Jun 27, 2022 · 0 comments
Open

Misunderstanding of Ex. 14.43 #45

icelandicinquisition opened this issue Jun 27, 2022 · 0 comments

Comments

@icelandicinquisition
Copy link

icelandicinquisition commented Jun 27, 2022

I first did the exercise the way it is done here, but I think there is a fundamental misunderstanding of the text. The number that has to be entered is not the divisor, but the dividend. Hence the "divisible by" in the exercise. For example, 100 (dividend) is entered and checked for 2, 3, 4 (divisor) and not 2 (divisor) checked for 80, 90, 100 (dividend).
A correct approach to solve this exercise can be found on https://github.com/pezy/CppPrimer/blob/master/ch14/ex14_43.cpp in my opinion.

This approach might be a bit odd at first (why defining std::modulus mod? Why not doing the straight solution by using %?) But using std::modulus is what the exercise asks for and since we have to enter a dividend and not a divisor, something like the solution in this link seems to me the way to go for.

@icelandicinquisition icelandicinquisition changed the title Missunderstanding of Ex. 14.43 Misunderstanding of Ex. 14.43 Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant