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
icon
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.
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
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Binary numbers
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr