Answer to Question #295281 in C++ for Zen

Question #295281

Create a program that reads trom the console two integer numbers (int) and prints now many numbers between them exists, such that remainder of their division by 5 is O. E

1
Expert's answer
2022-02-08T11:42:19-0500
#include <iostream>
using namespace std;

int main() {
    int a, b;
    int count=0;

    cout <<"Enter two integers: ";
    cin >> a >> b;


    for (int i=a; i<=b; i++) {
        if (i%5 == 0) {
            count++;
        }
    }

    cout << "There are " << count << " numbers between " << a
         << " and " << b << " (both inclusive) which are divided by 5";
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog