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
Best company who provides the best ISP (internet service provider)?
valina [46]

Answer:

Explanation:

all internet service providers are garbage. especially in america.

so i will focus on only the positives about one. even though  i know a bunch of bad things about this one.

AT&T is super innovative in that they are bringing fiber optic to many homes in America. Fiber optic is a new type of wiring that brings the fastest Internet never seen before, at speeds of one gigabit per second or even more. Furthermore, their technicians tend to resolve any issues with routers at home.

5 0
2 years ago
Write a class that specify the characteristics of a car, like type (sedan, jeep, mini, SUV, etc), gear (auto, manual), maximum s
iVinArrow [24]

Answer:

Answered below

Explanation:

This is written in Kotlin programming language.

//Creating the class Car. The primary //constructor declares car's properties which //are initialized when it's objects are created.

class Car(

val type: String,

val gear: String,

val maxSpeed: Double,

val avgFuelConsumption: Double)

//Creating several objects of car.

val sedan: Car = Car("sedan", "auto", 23.4, 500)

val jeep: Car = Car("jeep", "manual", 40, 350)

val mini: Car = Car("mini", auto, 26.7, 86, 234)

8 0
3 years ago
3. Encode these sentences in ASCII: a. "Stop!" Cheryl shouted. b. Does 2 + 3 = 5?​
Zepler [3.9K]

Answer:

"Stop!" Cheryl shouted.
34, 83, 116, 111, 112, 33, 34, 32, 67, 104, 101, 114, 121, 108, 32, 115, 104, 111, 117, 116, 101, 100, 46

Does 2 + 3 = 5?
68, 111, 101, 115, 32, 50, 32, 43, 32, 51, 32, 61, 32, 53, 63

I got these numbers with this python code:
print([ord(c) for c in '"Stop!" Cheryl shouted.'])
print([ord(c) for c in 'Does 2 + 3 = 5?'])

4 0
2 years ago
How can you tell that a website is valid and reliable?
larisa86 [58]
If there is an about page where it tells whom made the website, as well as a copyright 2016 on the bottom of the page. This basically means the website is useful and updated by the creators. Another factor which the site doesnt always need but if it has an https at the beginning of the url then it should be good and valid because that means the site is secured. Also factor in the sections where articles are present, if they have a date and an author towards the bottom or top of the article, then it can be trusted as well. Theres a lot more you can look for in a site and validating if it is an okay site but these are a few examples. Hope this helped!:)
3 0
3 years ago
In order for you to make a wireless connection it must first find an availble
erastova [34]
It sounds like you are looking for a network. If a node can not find a network to connect to, then it cannot connect.
7 0
3 years ago
Other questions:
  • An engineer is assigned to replace an older data-grade autonomous wireless network with a cisco controllerbased wireless network
    6·1 answer
  • Changes in computer technology have an effect on _____. computer scientists only people who work with computers only everybody p
    12·2 answers
  • In a certain computation, 90% of the work is vectorizable. Of the remaining 10%, half is parallelizable for an MIMD machine. Wha
    9·1 answer
  • Why is it important to use a structured cabling standard when installing and managing cabling systems?
    12·1 answer
  • In preparing his persuasive presentation, Reza should most likely focus on clearly presenting his
    6·2 answers
  • A manufacturing company inspects all products before selling them. Less than 1% are defective and do not pass inspection. You ar
    9·1 answer
  • Spreadsheet software can be used to do all the following except _____.
    5·2 answers
  • IN WHICH COUNTRY DO THEY LET YOU PLAY MINECRAFT IN SCHOOL?
    8·2 answers
  • Drag the tiles to the correct boxes to complete the pairs.
    13·1 answer
  • look for ten websites and classify them as static or dynamic what makes each websites static or dynamic?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!