garryhtreez

5.12

Nov 13th, 2020 (edited)
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. /* 5.12 Calculating the Product of the Multiples of 3
  2.    Deitel & Deitel C++ How to Program, 10th ed (Global Ed.)
  3.    Visual Studio Community 2019 */
  4.  
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int main(void) {
  9.  
  10.     int product{ 1 };
  11.     for (int i{ 3 }; i <= 50; i++)
  12.         if (i % 3 == 0) {
  13.             cout << "multiple found: " << i << endl;
  14.             product *= i;
  15.         }
  16.     cout << "The product of all of the multiples of 3 from 3 to 50: " << product;
  17.  
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment