We're going to take three consecutive integers and multiply them in order to get the cumulative product and print them out

Asked 2 years ago, Updated 2 years ago, 17 views

 Integer:2
Cumulative product:2
Integer: 4
Cumulative product: 8
Integer: 6
Cumulative multiplication:48

I'm trying to print it out, but I don't know how to code it Please help me

python

2022-09-20 19:27

1 Answers

I made it simple. c++

#include <iostream>
using namespace std;

int main() {
    int* arr = new int[3]{1,1,1};
    int temp = 1;
    for (int i = 0;i < 3;i++) {
        cout << "integer:";
        cin >> arr[i];

        for (int j = 0;j < 3;j++) {
            temp *= arr[j];
        }

        cout << "Cumulative product:" <<temp << endl;
        temp = 1;
    }
}


2022-09-20 19:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.