Write a simple program Multiplications of array in C++/C
#include <iostream>
using namespace std;
void display(int *arr, int n)
{
for (int i = 0; i < n; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
int multiplyofArray(int arr[], int n)
{
int multi = 1;
for (int i = 0; i < n; i++)
{
multi *= arr[i];
}
return multi;
}
int main()
{
int arr[] = {1, 2, 3, 4, 5};
int n = sizeof(arr) / sizeof(int);
cout << "The array is : ";
display(arr, n);
cout << "The Multiply array : " << multiplyofArray(arr, n) << endl;
}
Output is :
The array is : 1 2 3 4 5
The Multiply array : 120
0 Comments