passing arrays to functions - Who's the lucky winner?
A local supermarket is running a promotion: each Nth customer will receive one item for free. Customers names are sequentially given as array of strings (see template). Write a function that receives the array of customers, its size, and the N number as arguments, and prints the names of the lucky customers each in a new line. Sample Input 3 Sample output Rayan Bruce Richard Mary No idea what I did wrong… almost done but solarlern app don’t show what I did wrong. #include <iostream> #include <string> using namespace std; //complete the function void winners(string costumers[],int no,int n) { int k=1; for (int i=0 ; i<=n ;i++ ) { if ( (n*k-1)<=13 && n>0){ cout<<costumers[(n*k)-1]<<endl; k++; } if (n<=0) cout<<0; } } int main() { string customers[] = {"Alice", "Bob", "Rayan", "Emma", "Ann", "Bruce", "Synthia", "Daniel", "Richard", "Sam", "Nick", "Mary", "Paul"}; //getting the lucky number as input int n; cin >> n; //call function winners(customers, 13, n); return 0; }