1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vova2212 [387]
3 years ago
14

Remember partially filled arrays where the number of elements stored in the array can be less than its capacity (the maximum num

ber 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[])
{
}
Computers and Technology
1 answer:
MrMuchimi3 years ago
8 0

Answer:

Complete the main method as follows:

int num;

cin>>num;

int i = 0;

while(num!=0){

array[i] = num;  

cin>>num;

i++;

}

Complete the printArray function as follows:

void printArray(int array[]){

int i =0;

while(array[i]!=0){

   cout<<array[i]<<" ";

   i++;

}}

Explanation:

<u>Main method</u>

This declares a variable that gets input from the user

int num;

This gets input from the user

cin>>num;

This initializes a count variable to 0. It represents the index of the current array element

int i = 0;

while(num!=0){

This inserts the inputted number to the array

array[i] = num;

This gets another input  

cin>>num;

The counter is incremented by 1

i++;

}

The above loop is repeated until the users enters 0

<u>printArray method</u>

This declares the array

void printArray(int array[]){

This initializes a counter variable to 0

int i =0;

This is repeated until array element is 0

while(array[i]!=0){

Print array element

   cout<<array[i]<<" ";

Increase counter by 1

   i++;

}}

<em>See attachment for complete program</em>

Download cpp
You might be interested in
If I wanted to add code so that the costume of my sprite would change, what menu would I look under to find the "change costume"
Damm [24]

Answer:

D.) Looks

the costume is technically the look of your sprite, so looks is the correct answer

7 0
3 years ago
Gourmet pizza shop with a
Alja [10]

Answer:

B.Strong direct competition.

Explanation:

Netflix can be viewed by anyone and at anytime.

8 0
2 years ago
What term describes what an actor breaks when he addresses the audience directly from stage,like in Hamlet's "to be or not to be
Lera25 [3.4K]
It's the term, 'breaking the fourth wall.'

7 0
4 years ago
Which Statement below is most true about the CTE programs?
frozen [14]

Answer:

All of the above are correct about the CTE programs.

Explanation:

All of the statement that are mentioned here about CTE program are true.

CTE stands for career and technical education program. In this program, high career demand courses has been offered such as, health care, business management, Law, hospitality etc.

These as these course have high demand, therefore 6 of the 10 hardest to fill positions are in the technical field or require a CTE background.

As few of the courses are leading fields such as Heath care, STEM (Science, Technology, Engineering and Mathematics) and Information Technology that is why, half of the CTE learners enrolled in these courses.

In these classroom, students are interacted with employers to offers internships.  

All the statements about CTE program are true, so the most true option is all of above, which is option D.

3 0
4 years ago
A Grocery store has 184 shelves for bottled goods. Each shelf can hold 27 bottles. How many bottles will the shelves hold in all
liberstina [14]

Answer:

4,968

Explanation:

You just have to multiply

6 0
3 years ago
Read 2 more answers
Other questions:
  • If you come to a stumbling block and can't think of any more ideas, what could you do? select all that apply 2pts.
    11·2 answers
  • Which statement about creating folders is TRUE?
    15·2 answers
  • "Because Standard Error and Standard Ouput represent the results of a command and Standard Input represents the input required f
    6·1 answer
  • How do medical detectives investigate their cases?
    15·2 answers
  • What is online school like 6 sentences
    12·1 answer
  • Data owners ensure that only the access that is needed to perform day-to-day operations is granted and that duties are separated
    10·1 answer
  • Is there any difference beetween the old version of spyro released on the origional and the newer ones??? or is it only change i
    8·1 answer
  • Thinking about the career cluster, "Information Technology", which of these careers would typically NOT be included? (Choose thr
    10·2 answers
  • The internet is controlled by ______
    5·1 answer
  • What file can you edit on a linux system to configure shared folders using samba?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!