Could someone please help. I've been trying to work fix this piece of code to put into a project but I could not get it to work. I keep getting this error C2664: 'SumOfNumbers' : cannot convert parameter 1 from 'int' to 'double []' . I've worked every thing piece by piece but when I try to pass the array to the function I get the error and don't know what it means. Does C++ not allow what I'm trying to do?
Code:
#include <iostream>
using namespace std;
void SumOfNumbers(double Nbr[], int size);
int main()
{
int size, Sum;
int *arrayNumbers;
//const int size = 10;
cout << "How much values to be added: ";
cin >> size;
arrayNumbers = new(nothrow) int[size];
if(arrayNumbers == 0)
cout << "error";
else
{
for(int i = 0; i < size; i++)
{
cout << "Enter number: ";
cin >> arrayNumbers[i];
}
SumOfNumbers(arrayNumbers, size);
//delete[] arrayNumbers;
}
//const int *number = 0;
//number = new int[size];
//double arrayNumbers[10];
//for(int i = 0; i < size; i++)
//{
// cin >> arrayNumbers[i];
//}
////cout << *arrayNumbers;
//int value = SumOfNumbers(*arrayNumbers, size);
////cout << "Value is: " << Sum;
system("pause");
return 0;
}
void SumOfNumbers(int Nbr[], int size)
{
int Sum = 0;
for(int i = 0; i < size; i++)
{
Sum += Nbr[i];
}
cout << "Your numbers are: ";
for(int i = 0; i < size; i++)
cout << Nbr[i] << ", sum is " << Sum << "\n";
//return Sum;
}