Guest User

Untitled

a guest
Nov 9th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int sum=0,counter=0,avg,x,y;
  6.     cout << "Input numbers: "; cin >> x >> y;
  7.     for (int i = 0; i <y ; i++)
  8.     {
  9.         if (i%3==0||i%5==0)
  10.         {
  11.             if (x<i && y>i) {              
  12.                 sum += i;
  13.                 counter++;
  14.             }
  15.         }
  16.     }
  17.     avg = sum / counter;
  18.     cout << "The average of multiples is: " << avg << endl;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment