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
#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";
}
Comments
Leave a comment