Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* 5.12 Calculating the Product of the Multiples of 3
- Deitel & Deitel C++ How to Program, 10th ed (Global Ed.)
- Visual Studio Community 2019 */
- #include <iostream>
- using namespace std;
- int main(void) {
- int product{ 1 };
- for (int i{ 3 }; i <= 50; i++)
- if (i % 3 == 0) {
- cout << "multiple found: " << i << endl;
- product *= i;
- }
- cout << "The product of all of the multiples of 3 from 3 to 50: " << product;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment