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
The radix sort
Taya2010 [7]

Answer:

A.Treats array entries as if they were strings that have same length.

Explanation:

The radix sort treats the array values as the strings.First it compares the LSB(Least Significant Bit) of the array values and then moves to the right one by one upto MSB(Most Significant Bit).So we can say that the radix sort treats the entries of the array as strings and compare them.So the answer is option A.

4 0
4 years ago
The Linux operating system is widely used in industry, especially for servers. Why do you believe this is the case?
Anit [1.1K]

Answer:

Asking why Linux is used as a server operating system? It has many advantages

Explanation:

1. Linux has very small kernel footprints

It can be on a USB, embedded system and the like.

2. Requires very little hardware resource to run.

Building on the first point, Linux dos not need much jard ware resource to run implying it can be run on outdated CPUs, a low RAM size, small disk space and it would be possible - doesn't matter with Linux - bar the effect on performance.

3. Linux runs 80% of the Internet today

4. It's free

...... and so much more.

- Reference: Andrew Holcomb, Quorate

How Linux compares with other OS - like Windows or Mac?

May Help:

https://www.quora.com/What-are-the-advantages-of-Linux-as-a-server-operating-system

Recommendation: Jason Montoya and Glen Becker, BI Analyst, SAS Expert

6 0
3 years ago
How can you access the Help and Support system?
Ne4ueva [31]
By going to the person on the bottom and there should be a tab
5 0
3 years ago
Read 2 more answers
Does a wizard function allow the user to enter or modify data in the records? select yes or no
mojhsa [17]
Yes wizard function allows you to modify records

4 0
3 years ago
6. What is the correct way to write 340,000,000 in scientific notation? (1 point
givi [52]

Answer:3.4X10^8

Explanation:

4 0
3 years ago
Other questions:
  • An administrator working on a Windows Server 2016 Server Core installation needs to disable DHCP on all interfaces on the server
    12·1 answer
  • What is a basic operation of computers
    13·1 answer
  • Paragraph: Read the following two e-mail messages. In a paragraph of no less than 125 words, explain why e-mail B is the more ap
    11·1 answer
  • Suppose you are consulting for a bank that's concerned about fraud detection, and they come to you with the following problem. T
    13·1 answer
  • A Gym Masters system programmer has just installed the first Windows Server 2016 sys- tem and now needs to do an initial configu
    13·1 answer
  • A malicious program that can replicate and spread from computer to computer?
    10·2 answers
  • A user complains because the social media apps on his mobile device always note his location. The user is worried about privacy,
    14·1 answer
  • a. a large central network that connects other networks in a distance spanning exactly 5 miles. b. a group of personal computers
    7·1 answer
  • Definition of data redundancy​
    8·1 answer
  • Which term accurately describes agile and devops
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!