I am a newbie programmer in c++ started my Computer Science degree. I got a problem with my assignment.
You need to make a function
char calculate_daily_sale(int [])
.
You need to define and read an array of integer values of length 10 in themain()
function.
Write a functioncharcalculate_daily_sale (int [])
that accepts the array as argument from themain()
function. The function will sum the values of array. If the values are greater than or equal to 15,000 the function return ‘y’ back to the main function, otherwise ‘n’ is returned from the function.
This is the code that I managed to write:
#include <iostream>
using namespace std;
char calculate_daily_sale(int[])
{
int arr[10];
int *ptr[10];
int sum=0;
for(int j=0; j<=9; j++)
{
ptr[j]=&arr[j];
sum=sum+arr[j];
cout<<sum;
}
}
int main()
{
int n,y;
int arr[10];
int *ptr[10];
for(int i=0; i<=9; i++)
{
ptr[i]=&arr[i];
cin>>*ptr[i];
}
if(calculate_daily_sale(int[])>=15000)
{
return y;
}
else
{
return n;
}
return 0;
}
The error that I am getting is:
expected primary expression before 'int'