hi, I'm miah and i need help for a project.

our task is to create a program that will ask user a positive integer until the user inputted a non-positive number or 0 and then display the product of all positive inputs. Use the following function prototypes. int accept_number();, bool ispositive(int);, int product(int, int);, void display(int);.

the output should look like this:

Enter a number: 3
Enter a number: 10
Enter a number: 2
Enter a number -213
The product is 60.

While it's not using the requested function formats, it'll do what you want plus more.

#include<stdio.h>
#include<iostream>

    int products(int arr[], int len) {
        int i, temp = 1;
        for (i = 0; i < len; i++) {
            temp = temp * arr[i];
        }
        return temp;
    }

    int num = 0; 

    int main()
    {   
        int count = 0;
        int arr[]{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; // multiply upto 16 numbers

        while (true) {
            std::cout << " Enter number: ";
            std::cin >> num;
            if (num > 0) {
                arr[count] = num;
            }
            count++;
            if (count >= 16)
            {
                std::cout << " The maximum numbers to multiply 16." << std::endl;
            }

            int len = sizeof(arr) / sizeof(arr[count]);
            int value = products(arr, len);
            if (num <= 0) {
                for (int i = 0; i < count; i++) {
                }
                std::cout << "The product is " << value << std::endl;
                int arr[]{ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }; //reset
                count = 0;
            }
        }
            return 0;
    }

     Enter number: 10
     Enter number: 20
     Enter number: 30
     Enter number: 40
     Enter number: -6
    The product is 240000
     Enter number: 1
     Enter number: 2
     Enter number: 3
     Enter number: 4
     Enter number: -5
    The product is 24
     Enter number:
commented: Please don't give free code away like this. Also, please check the date of the post you are replying to. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.