Remember partially filled arrays where the number of elements stored in the array can be less than its capacity (the maximum number of elements allowed). We studied two different ways to represent partially filled arrays: 1) using an int variable for the numElems and 2) using a terminating value to indicate the end of elements called the sentinel value. In the code below, please fill in the details for reading values into the latter type of array that uses a sentilnel value. Don't forget to complete the printArray function. #include using namespace std; void printArray(int array[]); // Implement printArray as defined with one array parameter int main() { const int CAPACITY=21; int array[CAPACITY]; // store positive/negative int values, using 0 to indicate the end of partially filled array cout <<"Enter up to " << CAPACITY-1 << " non-zero integers, enter 0 to end when you are done\n"; //To do: Write a loop to read up the int values and store them into array a. // Stop reading if the user enters 0 or the array a is full. //To do: store 0 to indicate the end of values in the array //Display array function printArray(array); return 0; } // To do: implement display for the given array void printArray(int array[]) { }

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter8: Arrays
Section: Chapter Questions
Problem 4MQ2
icon
Related questions
Question

Remember partially filled arrays where the number of elements stored in the array can be less than its capacity (the maximum number of elements allowed). We studied two different ways to represent partially filled arrays: 1) using an int variable for the numElems and 2) using a terminating value to indicate the end of elements called the sentinel value. In the code below, please fill in the details for reading values into the latter type of array that uses a sentilnel value. Don't forget to complete the printArray function. 

 

#include <iostream>
using namespace std;

void printArray(int array[]);
// Implement printArray as defined with one array parameter

int main()
{
const int CAPACITY=21;
int array[CAPACITY]; // store positive/negative int values, using 0 to indicate the end of partially filled array

cout <<"Enter up to " << CAPACITY-1 << " non-zero integers, enter 0 to end when you are done\n";

//To do: Write a loop to read up the int values and store them into array a.
// Stop reading if the user enters 0 or the array a is full.

 


//To do: store 0 to indicate the end of values in the array


//Display array function
printArray(array);

return 0;
}

// To do: implement display for the given array
void printArray(int array[])
{


}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Array
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.
Similar questions
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,