Consider the following function.  void printArray(int cards[], int size) {  for (int i=0; i

icon
Related questions
Question
100%

Consider the following function. 

void printArray(int cards[], int size)
{
 for (int i=0; i<size; i++)
 {
cout << cards[i] << endl; 
cards[i] = 0;
 }
}

It prints the array, but also sets the elements to zero, which seems like a bug for a function that should only print the array.  How could we prevent this function from compiling?

A) Change i<size to i<=size

B) Change void to  int

C) Insert keyword const before parameter int cards[]

D) Change for to while

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.