Write a C PROGRAM that counts the number of integers from 1 to M that are divisible by N. Use the sample run as guide below. Note, that the program repeats until an invalid input is encountered.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.4: A Case Study: Rectangular To Polar Coordinate Conversion
Problem 9E: (Numerical) Write a program that tests the effectiveness of the rand() library function. Start by...
icon
Related questions
icon
Concept explainers
Question

Write a C PROGRAM that counts the number of integers from 1 to M that are divisible by N. Use the sample run as guide below. 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: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 4 steps with 2 images

Blurred answer
Knowledge Booster
Operators
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++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
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