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[])
{
}

Answers

Answer 1

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:

Main method

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

printArray method

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++;

}}

See attachment for complete program


Related Questions


Question 12 of 30
In Alienware systems, errors are indicated via the tricolor Power Button LED.
True
False

Answers

Answer:

False.

Explanation:

Bought the latest Alienware 15 r3 with i7 7th gen, 1060gtx, etc. Next day laptop wont post, turns on, reboots, then does the same thing, meanwhile the power led button blinks 6 times. So making a little research and its seems like a video card is kaput, dont know if its the intel or the nvidia. Aynway, I bought this laptop from a company in Canada, and it seems it was alredy registered so I cand procced with a transfership ownership.

Answer:

I think the answer

is true.

How can you create the first row of the table as the header of the table?
In the Insert Table dialog box, you select the ______
checkbox to create the first row as the header of the table.

Answers

Answer:

table style option

Explanation:

Answer: table style

Explanation:

Consider the following static method, calculate.

public static int calculate(int x)
{
x = x + x;
x = x + x;
x = x + x;

return x;
}
Which of the following can be used to replace the body of calculate so that the modified version of calculate will return the same result as the original version for all values of x?

return 8 * x;
return 3 + x;
return 3 * x;
return 6 * x;
return 4 * x;

Answers

Answer:

return 8 * x

Explanation:

Given

The attached code segment

Required

Which single statement can replace the program body

From calculate(), we have:

[tex]x = x + x;\\ x = x + x;\\ x = x + x;[/tex]

The first line (x = x + x) implies that:

[tex]x=2x[/tex]

So, on the next line; 2x will be substituted for x

i.e.

[tex]x = x + x[/tex] becomes

[tex]x = 2x + 2x[/tex]

[tex]x = 4x[/tex]

So, on the third line; 4x will be substituted for x

i.e.

[tex]x = x + x[/tex] becomes

[tex]x = 4x+ 4x[/tex]

[tex]x = 8x[/tex]

In programming: 8x = 8 * x:

This means that: return 8 * x can be used to replace the body

The memory hierarchy of a computer system organizes storage by using small, fast, expensive memories at the top of the hierarchy and supplementing them with larger, slower, cheaper memories at each successive level. Explain how the principle of memory locality makes such a system capable of providing efficient access to the data and instructions needed for executing programs.

Answers

Answer:

Following are the responses to this question:

Explanation:

The computer system's memory hierarchy arranges space through tiny, fast, costly stocks only at top of the pyramid and complements them through big, lighter, cheap storage facilities at every representation made. It is needed to limit the time for data access for application executes. A very design of the main memory allows a system to have easy access to the information and instructions necessary to execution time. A traditional technique of system memory works like:

[tex]Level\ 0 (Top Level) \to CPU \ Registers\\\\Level \ 1 \to Cache\ Memory \ (SRAMs)\\\\Level\ 2 \to Main \ Memory \ (DRAMs)\\\\Level \ 3 \to Magnetic \ Disk\ (Disk \ Storage)\\\\Level \ 4 \to Optical \ Disk\\\\Level \ 5 \to Magnetic\ Tape\\\\[/tex]

Because as memory cost rises below level 5 to level 0. CPU registers become costly as the cache memory, which then, in turn, is much more costly than for the memory.

Whenever the access time of CPU registries becomes reduced from level 5 to level 0, its time complexity between reading/write transactions is much more swift than Cache Memory Access period which in turn is quicker than that of the main memory Communication cost and so forth.

So, we need a memory hierarchy to analyze the information (read/write requests) efficiently, in turn for all the top-level to read the information more quickly and thoroughly. Therefore, the architecture of the computer program's Main memory enables a system to provide secure access to information and guidance for running programs.

please help me on this coding problem :)

Consider the following code segment.

int a = 0;
int b = 3;

while ((b != 0) && ((a / b) >= 0)
{
a = a + 2;
b = b - 1;
}
What are the values of a and b after the while loop completes its execution?

a = 4, b = 1
a = 0, b = 3
a = 6, b = 0
a = 8, b = -1

Answers

Answer:

a=4 , b=1

Explanation:

I'm not a computer science major at all but I think I can help you with this code.

Our program wants us to add 2 to a get new a value while also subtracting 1 from b value to obtain new b value. We we want to for for as long b is not 0 and a/b is nonnegative.

One round we get:

New a=0+2=2

New b=3-1=2

Let's see if we can go another round:

New a=2+2=4

New b=2-1=1

We can't go another round because b would be negative while a is positive which would make a/b negative. So our loop stops at this 2nd round.

a=4 , b=1

Other notes:

2nd choice makes no sense because a is always going to increase because of the addition on a and b was going to decrease because of the subtraction on it.

Third choice makes no sense because a/b doesn't even exist.

Fourth choice a/b is negative not nonnegative.

In JavaScript what is the resulting value of answer for answer = 5 + 3 * 2? Explain why the answer is not 16.

Answers

Answer:

with this type of math , you actually multiply first before you add

Explanation:

2×3 =6.

6+5=11.

JavaScript is the resulting in the value are the of answer for answer = 5 + 3 × 2 = 11. It was not the 16.

What is JavaScript?

The word JavaScript refers to a text-based programming language, and the server-side is what allows users to make web pages interactive. HTML and CSS are two programming languages that are used to make web pages dynamic.

According to the JavaScript, are the resulting the values, and they define are the answer.

As per the rule of the bod mas rule.

5 + 3 × 2 = ?

3 × 2 = 6

5 + 6 = 11

As a result, the JavaScript are the based on the resulting in the value 5 + 3 × 2 = 11.

Learn more about on JavaScript, here:

https://brainly.com/question/28448181

#SPJ2

1. Define Primary Key. Why do we need primary key ?

2. Define Field size.

3. Define Validation Rule.

4. . Not leaving the house and a lack of exercise can cause health problems like obesity. TRUE OR FALSE

5. Rebecca only works 3 days in a week but she works longer hours each day to ensure she hits the 40-hour work week.
-art-time working
-Compressed hours
-Job sharing
-Flexible hour

Answers

Answer:

1 .The main purpose of primary key is to identify the uniqueness of a row, where as unique key is to prevent the duplicates, following are the main difference between primary key and unique key.

Explanation:

2. Field size means the dimensions along the major axes of an area in a plane perpendicular to the central axis of the useful beam of incident radiation at the normal treatment distance and defined by the intersection of the major axes and the 50 percent isodose line.

When it comes to paying bills at restaurants, Wallace always leaves a 15% tip based on the pretax price. However, Wallace is tired of computing tips every time, please construct a function total_bill, which takes a numerical argument pretax and returns the total bill by 1) calculating the tip, 2) the after-tax price, and 3) adding the tip to the after-tax price. Assume the sale tax is 9%. Below is how the function would be used:
pretax = 15
print('The total bill is ${}'.format(total_bill(pretax)))
The output should be:
The total bill is $18.6

Answers

Answer:

where are the answers.

Explanation:

What are the characteristics of a good text-based adventure game? In other words, what are some features that should be in the game to make it appealing to players?

Answers

Answer:

spelling and good format

Explanation:thats all i know

Can someone help me calculate this Multimedia math:

A monochrome sequence (black and white) uses a frame size of 176 x 144 pixels and has 8 bits/pixels. Registered with Frame Rate 10 frames/sec. Video is transmitted through a 64 Kbit/sec bandwidth line.
(a) Calculate Compression Ratio (Crude Bit Speed / Compressed Bit Speed) which will be needed.
(b) What will happen if the Ratio compression is higher than it in (a)?
(c) What will happen if the Ratio compression is lower than it in (a)?

Answers

Answer:

I will try to help you answer this. it seems really confusing but I'll do my best to solve it and get it back to you. Hope I'm able to help!

What programming language does the LMC 'understand'?

Answers

Answer:

The LMC is generally used to teach students, because it models a simple von Neumann architecture computer—which has all of the basic features of a modern computer. It can be programmed in machine code (albeit in decimal rather than binary) or assembly code.


Please help meeee , you will get 20 points

Answers

Answer:

true

Explanation:

true trueee 3uehehehdgeyeyehhehehegegegrhrtggrevegrgrhehehru

I THINK IT FALSE

#Carry on learning

When is blue for when the instance in which the directory of compulsion in the air!

Answers

I think it’s what the other person said

Where should a photographer place lights for a headshot? Headshot lighting is more important with darker backgrounds. The light should be at a 45-degree angle from the subject. The light should be in front of the subject. The third light should be the subject to form a ring of light around the subject’s hair.

Answers

Answer:

Headshot lighting is more important with darker backgrounds. The  

(key)  light should be at a 45-degree angle from the subject. The  

(fill)  light should be in front of the subject. The third light should be  

(behind) the subject to form a ring of light around the subject’s hair.

Explanation:

i searched it up individually and thats what i got

what is the perpose of the boolean variable swaps in this buble sort algorithm

Answers

Answer:

“Bubble Up” algorithm will move largest

value to its correct location (to the

right/end of array)

• Repeat “Bubble Up” until all elements are

correctly placed:

– Maximum of N-1 times

– Can finish early if no swapping occurs

• We reduce the number of elements we

compare each time one is correctly placed

See the picture and answer the coding question

Answers

Answer:

Actually I don't know computer so I can't help you sorry bro

Take a better picture please

29. Write a program in a script file that calculates the cost of renting a car according to the following price schedule: The program asks the user to enter the type of car (sedan or SUV), the number of days, and the number of miles driven. The program then displays the cost (rounded to cents) for the rent. Run the program three times for the following cases: (a) Sedan, 10 days, 769 miles. (b) SUV, 32 days, 4,056 miles. (c) Sedan, 3 days, 511 miles.

Answers

Answer:The price for renting a car at a car rental company is according to the following schedule: Write a MATLAB program in a script file that calculates the cost of renting a car based on the shown price schedule. The program must ask the user to enter the type of car (Sedan or SUV), the number of days, and the number of miles driven. The program then displays the cost (rounded to cents) for the rent in a sentence that reads: "The cost of the rent is XXX $." where XXX is the cost value in $. Run the program three times for the following cases: Sedan, 10 days, 769 miles. SUV, 32 days, 4, 056 miles. Sedan, 3 days, 511 miles. Use fprintf () to display the text and data. The data should be displayed in f format with two decimal digits.

Explanation:

A restaurant recorded the ages of customers on two separate days. You are going to write a program to compare the number of customers in their twenties (ages 20 to 29). What is the missing line of code to count the number of customers in their twenties? customerAges = [13, 3, 11, 24, 35, 25, 15, 18, 1] count20s = 0 if 20 <= item <= 29: count20s = count20s + 1

Answers

Answer:

You will need to implement a for loop ( I am assuming this is java)

Explanation:

int count20s = 0;

for(int x =0; x< customerAges.length;x++){

if(20 <= customerAges[x] && customerAges[x] <= 29){

     count20s++;

}

PLZZ HELP HELP EL
SMMSNSM

Answers

Answer:

jfhhdbdbfjdjdvebbebzbdbd

Consider the following class declarations.

public class Dog
{
private String name;
public Dog()
{
name = "NoName";
}
}
public class Poodle extends Dog
{
private String size;
public Poodle(String s)
{

size = s;
}
}

The following statement appears in a method in another class.
Poodle myDog = new Poodle("toy");
Which of the following best describes the result of executing the statement?

a. The Poodle variable myDog is instantiated as a Poodle. The instance variable size is initialized to "toy". The instance variable name is not assiged a value.
b. The Poodle variable myDog is instantiated as a Poodle. The instance variable size is initialized to "toy". An implicit call to the no-argument Dog constructor is made, initializing the instance variable name to "NoName".
c. The Poodle variable myDog is instantiated as a Poodle. The instance variable size is initialized to "toy". An implicit call to the no-argument Dog constructor is made, initializing the instance variable name to "toy".
d. A runtime error occurs because super is not used to call the no-argument Dog constructor.
e. A runtime error occurs because there is no one-argument Dog constructor.

Answers

Answer:

The poodle variable myDog is intentioned as a Poodle. The instance variable size is initialized to “toy”. The instance variable name is not assigned a value.

D have a good one pal let me know

.
T
Which of the following objects are not contained within
an Access database?
Select one:
a Tables and forms,
b. Queries and reports.
c. Macros and Modules
d. Web sites and worksheets​

Answers

Answer:

17 38 ay

Explanation:

a


Imaging a computer is part of what phase of conversion?
a. Backup
b. Configuration
c. Procurement

Answers

B. Because the computer can rearrange itself when it is in a phase of conversion

3.5.6 Introduce Yourself, Part 2


please hellllpp it keeps saying the code is wrong

Answers

Answer:

In Python:

name = "Arthur"

age = "62"

print("Hi! My name is "+name+" and I am "+age+" years old")

Explanation:

Given

See attachment

Required

Write a code to introduce yourself

Initialize name

name = "Arthur"

Initialize age

age = "62"

Print introduction

print("Hi! My name is "+name+" and I am "+age+" years old")

HELP PLEASE
What will be printed to the console after this program runs?
var numbers = [2, 5, 3, 1, 6]
function changeNums(numList, addNum, subtractNum) {
for(var i=0; i if(numList[i] % 3 == 0){
numList[i] = numList[i] + addNum;
} else {
numList[i] = numList[i] - subtract Num;
}
}
}
changeNums (numbers, 3, 2);
console.log(numbers);

Answers

The output that will be printed to console after the program runs is (b) [0, 3, 6, -1, 9]

When the program is analyzed, we have the following highlights

The program increases numbers that are divisible by 3, by the value of variable addNumOther numbers are reduced by the value of variable subtractNum

In the program, the values of addNum and subtractNum are 3 and 2, respectively.

In the list, 3 and 6 are divisible by 3

2, 5 and 1 are not divisible by 3

When the program runs, 3 and 6 are replaced by 6 and 9.

While 2, 5 and 1 are replaced by 0, 3 and -1

Hence, the output that will be printed to console after the program runs is (b) [0, 3, 6, -1, 9]

Read more about similar programs at:

https://brainly.com/question/24833629

please help
Consider the following code segment.

int a = 0;
int b = 3;

while ((b != 0) && ((a / b) >= 0)
{
a = a + 2;
b = b - 1;
}
What are the values of a and b after the while loop completes its execution?

a = 4, b = 1
a = 0, b = 3
a = 6, b = 0
a = 8, b = -1

Answers

Answer:

a = 6, b = 0

Explanation:

The loop ran 3 times before b == 0. The statement "while ((b != 0)" is essentially saying: 'While b is not equal to 0, do what's in my loop'. Same general thing with "&& ((a / b) >= 0)". The "&&" is specifying that there should be another loop condition. The final part of the while loop states: 'as long as a ÷ b is greater than 0, do what's in my loop'. If all of these conditions are met, the loop will run. It will continue to run until at least one of the conditions are not met.

Side note: I can't help but notice you posted the same question a while ago, so I just copied and pasted my previous response with some tweaking here and there. Hope this helps you! :)

king(a. has eaten b.ate c.had eaten) when Airah called​

Answers

Answer:

c

Explanation:

king had eaten when Airah called

An administrative assistant is responsible for scheduling appointments at a doctor’s office. Which component would allow the administrative assistant to enter each patient’s name, date of birth, doctor’s name, and appointment date and time?

Answers

Answer: Form

Explanation:

Answer:

A on edge

Explanation:

You are asked to write a program that will display a letter that corresponds with a numeric rating system. The program should use a switch statement. The numeric rating is stored in a variable named rate and rate may equal 1, 2, 3, or 4. The corresponding letter is stored in a variable named grade and grade may be A, B, C, or D. Which is the test expression for this switch statement

Answers

The switch statements are similar to the if statements in a computer program

The test expression for the switch statement is the variable rate

How to determine the test expression

From the question, we have the following highlights

The program displays a corresponding letter of a rateThe rating is stored in the variable rate

This means that, the numerical value of the variable rate would be tested and the corresponding letter would be printed

Hence, the test expression for the switch statement is the variable rate

Read more about computer programs at:

https://brainly.com/question/16397886

How many cycles would it take to complete these multicycle instructions after pipelining assuming: Full forwarding 1 Adder that takes 2 cycles (subtraction uses the adder) 1 Multiplier that takes 10 cycles 1Divider that takes40 cycles 1 Integer ALU that takes1cycle(Loads and Stores) You can write and read from the register file in the same cycle. Begin your your cycle counting from 1 (NOT 0)

Answers

js downs djdknsekmnd

Write Inheritance program for the following scenario. Employee is super class where as Manager and Regular are the sub class. Partial Employee class is created, you have to complete the Employee class and implement Manager and Regular class. The main is class is given that creates objects of all classes and displays the output.
• The subclasses uses super keyword in the constructor to assigned the data.
• All the classes implements toString() method.

Answers

Answer:

Explanation:

public class Employee{

//Existing employee code

public String getName(){

return Name;

}

public double getSalary(){

return salary;

}

public int getId(){

return id;

}

public void setName(String name){

this.name = name;

}

//Manager Class

public class Manager extends Employee{

private double bonus;

public Manager(int id,String name,double salary,double bonus){

super(id,name,salary);

this.bonus = bonus;

}

public void setBonus(double bonus){

this.bonus = bonus;

}

public double getBonus(){

return bonus;

}

}

//Regular Class

public class Regular extends Employee{

private double overtime;

public Manager(int id,String name,double salary,double overtime){

super(id,name,salary);

this.overtime = overtime;

}

public void setOvertime(double overtime){

this.overtime = overtime;

}

public double getOvertime(){

return overtime;

}

}

Other Questions
what is the total surface area in square millimeters, of the rectangle solid shown below? HELP PLEASE! name a pair of parallel lines What is the difference between the isotopes Hydrogen-2 and Hydrogen-3? brainliest. markkkinggg All organisms get energy from their environment. When a shark consumes food,the remora fist collects the food scraps by swimming underneath the shark. What type ofrelationship is demonstrated by the shark and the remora fish?a. Commensalismb. Mutualismc. Neutralismd. Parasitism 1. Which of these phrases is a good definition for evidence. A proof for a claim. B examoles of an idea. C answer to a question. d important category What is the slope of the line that passes through (1,3) (5,15) Describe how the graph of y=2x and y=2x+7 are the same. A person viewing this article is MOST LIKELY going to get the impression thatA) The product advertised is very expensive B) The product advertised is for young people C) The product advertised is for both men and womenD) The product advertised is from an earlier time in history In what ways do your prejudices impact your decisions about beingkind? Which of these best reveals a storys theme? A. the length of the storys rising action B. the way the central conflict is resolved C. the way the characters interact with the setting D. the relationship between the protagonist and the antagonistWhich of these The weight of a bucket of fish was more than 23 pounds. Doria wants to write an inequality for the weight of the bucket of fish. She uses the variable w to represent the weight. Which inequality should Doria write? w greater-than negative 23 w greater-than 23 w less-than 23 w less-than negative 23 Nathan is 3 years older than Olivia. Determine the equation if n represents the age of Nathan and o represents the age of Olivia.A. n = o + 3B. o = n + 3C. n = 3oD. o = 3n What is the best free website to learn slope? I haven't learned a single thing in school since the pandemic and I need to learn slope for my test. Any suggestions? can someone help please?!! what is the central idea of the text in animal farm Think about the writing prompt, and then write an effective research question for the topic. About Sparta and Athens What value of w is a solution to this equation?w/2 = 6w = 10 or w = 12 Est-ce que tu ___ aller en France bientt?vasvaallesvais PLEASE I ACTUALLY NEED HELP ;(