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
Read the citation example, and then use the drop-down menus to identify each part.
Lemur [1.5K]

Answer:

im notur e

Explanation:

5 0
3 years ago
Read 2 more answers
Wendy Patel is entering college and plans to take the necessary classes to obtain a degree in architecture. Research the program
jeka57 [31]

Answer:

Follows are the solution to this question:

Explanation:

If Windy needs to study and be a specialist in graphic designing for machines, I'm going to provide a windy link of the machine with such a 64 bit, 3-GHz Intel or AMD processor with an 8 GB  RAM, an OpenGL 4.1 chip, an inter-button cursor, a right thumbstick, or a storage drive with GB at least.  

  • All above description for the computer is suitable for windy because you would well be aware throughout the graphic designing, that may be learned through iRhino 3D (iOS), Autocad, Magical Plan, Morphoio trace, etc if you'd like to graduation in architecture.
  • They require fast internet for each application, that can also be installed and installed, that  often requires a profile of all technical support programs as well as a web-only storage license.  
  • As many of the above applies also runs through an AMD or six-bit intel, but not on the ARM processor or instance  iRhino 3D (iOS) isn't consistent with an Embedded system, I will select the processor like an Intel or 3GHz AMD processor.
4 0
3 years ago
Carbon copy others who are..
My name is Ann [436]

Answer:

Is it Multiple Choice Question?

5 0
3 years ago
Read 2 more answers
What are the types of action involving data base?
Alexeev081 [22]

Answer: The DBMS is a software system that explains the four types of actions, which are defining, constructing, manipulating, and sharing databases among various users and applications.

3 0
3 years ago
Select the correct category of cybersecurity described.
Shalnov [3]

Answer:

Network security

Explanation:

Network security is a category of cybersecurity that is related to the protection of the infrastructure of the computer network from unauthorized access and intrusion that may be from intended attack or from an expedient  program which may result in the modification, malfunctioning, misuse or unacceptable disclosure of the network and the contents of the network

The category of cybersecurity that 'prevents intruders from accessing, misusing, destroying, adapting, or improperly disclosing networks, network infrastructure, or the information contained within networks' is network security.

6 0
2 years ago
Other questions:
  • Using a wireless network without the network owner's permission is known as ________.
    15·1 answer
  • A _________ consists of a set of computers that interconnect by means of a relatively unsecure network and makes use of encrypti
    5·1 answer
  • The first widely adopted windows product, ____, featured a standardized look and feel, similar to the one made popular by apple'
    11·1 answer
  • Jill is setting up a presentation and wants to use a built-in equation, such as the area of a triangle. To insert this in her pr
    14·2 answers
  • Which button will allow you to insert quotes and notes into text into a document​
    12·1 answer
  • Person-name: String+setName(String name): void+getName(): String^Student-studentID: long+Student(String sname, long sid)+setID()
    10·1 answer
  • Which button would you use to insert a downloaded video clip on your computer into a slide?
    15·2 answers
  • What icon is usually used to indicate an attachment feature?
    14·2 answers
  • Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the ou
    10·1 answer
  • A location in memory which stores a value, the value can change as the program is running is
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!