nt the number of integers from 1 to M that are divisible by N. 3 4 ntegers from 1 to 3 that are divisible by 4. 4 2 tegers from 1 to 4 that are divisible by 2. 4 3
nt the number of integers from 1 to M that are divisible by N. 3 4 ntegers from 1 to 3 that are divisible by 4. 4 2 tegers from 1 to 4 that are divisible by 2. 4 3
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 29PE
Related questions
Question
![Write a program that counts the number of integers from 1 to M that are divisible by N. Use the sample run as guide. Note, that the program repeats until an invalid
input is encountered.
Sample run:
Program to count the number of integers from 1 to M that are divisible by N.
Enter M (>1): 3
Enter N (>1): 4
There are no integers from 1 to 3 that are divisible by 4.
Enter M (>1): 4
Enter N (>1): 2
There are 2 integers from 1 to 4 that are divisible by 2.
Enter M (>1): 4
Enter N (>1): 3
There is 1 integer from 1 to 4 that is divisible by 3.
Enter M (>1): -5
You have entered an invalid input. Program will now terminate.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffc60c5e4-3667-4df8-85dc-c0a92f6e860c%2F0221aa90-ef2d-4c57-8422-7c2626ee3eaa%2F7t6er8d_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Write a program that counts the number of integers from 1 to M that are divisible by N. Use the sample run as guide. Note, that the program repeats until an invalid
input is encountered.
Sample run:
Program to count the number of integers from 1 to M that are divisible by N.
Enter M (>1): 3
Enter N (>1): 4
There are no integers from 1 to 3 that are divisible by 4.
Enter M (>1): 4
Enter N (>1): 2
There are 2 integers from 1 to 4 that are divisible by 2.
Enter M (>1): 4
Enter N (>1): 3
There is 1 integer from 1 to 4 that is divisible by 3.
Enter M (>1): -5
You have entered an invalid input. Program will now terminate.
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 5 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr