int main() { int a = 0; int b = 0; int sum = 0; unsigned count = 0; cin >> a >> b; for (; a <= b; ++a) { if (a % 3 == 0) { count++; sum += a; } } if (count > 0) { cout << "Avg sum of numbers = " << (double)sum / count; } else { cout << "There are no numbers that are divisible by three"; } return 0; }
using namespace std;
int main()
{
int a = 0;
int b = 0;
int sum = 0;
unsigned count = 0;
cin >> a >> b;
for (; a <= b; ++a) {
if (a % 3 == 0) {
count++;
sum += a;
}
}
if (count > 0) {
cout << "Avg sum of numbers = " << (double)sum / count;
} else {
cout << "There are no numbers that are divisible by three";
}
return 0;
}