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
natka813 [3]
3 years ago
15

Write a do - while loop to get 20 numbers from the user and sum them together. output the sum after the loop. declare any variab

les you need.
Computers and Technology
1 answer:
Lilit [14]3 years ago
8 0
A do while loop in this situation is actually stupid. A for loop or while loop will suit this purpose better, since you do not need to make sure it executes at least once for the given condition. Do while loops are good for situations where the condition may not be true initially, and you'd like to guarantee execution at least once. E.g circular linked list node counter.
You might be interested in
Each array in Java has a public field named ________ that contains the number of elements in the array.
Helen [10]

Answer:

length.

Explanation:

length variable determines the size of the array or the number of elements in the array.length variable is a final variable.It is a public field.It is only applicable for array it is not applicable for strings.It is also used to directly access the field member of the array.So we conclude that the answer is length.

7 0
4 years ago
As you will solve more complex problems, you will find that searching for values in arrays becomes a crucial operation. In this
sergeinik [125]

Answer:

#include<iostream>

using namespace std;

int main() {

cout<<"Enter The Size Of Array: ";

int size;

bool isBestCase=false;

cin>>size;

if(size<=0){

cout<<"Error: You entered an incorrect value of the array size!"<<endl;

return(0);

}

int array[size], key;

cout<<"Enter the numbers in the array, separated by a space, and press enter:";

// Taking Input In Array

for(int j=0;j<size;j++){

cin>>array[j];

}

//Your Entered Array Is

for(int a=0;a<size;a++){

cout<<"array[ "<<a<<" ] = ";

cout<<array[a]<<endl;

}

cout<<"Enter a number to search for in the array:";

cin>>key;

for(i=0;i<size;i++){

 if(key==array[i]){

   if(i==0){

     isBestCase=true; // best case scenario when key found in 1st iteration

     break;

   }

 }

}

if(i != size){

 cout<<"Found value "<<key<<" at index "<<i<<", which took " <<++i<<" checks."<<endl;

}  else{

 cout<<"The value "<<key<<" was not found in array!"<<endl;

 cout<<"We ran into the worst-case scenario!"; // worst-case scenario when key not found

}

if(isBestCase){

cout<<"We ran into the best case scenario!";

}

return 0;

}

Explanation:

The C++ source dynamically generates an array by prompting the user for the size of the array and fills the array with inputs from the user. A search term is used to determine the best and worst-case scenario of the created array and the index and search time is displayed.

5 0
3 years ago
To mark all modifications made to the document, activate the
Mariulka [41]

Answer:

Compare

Explanation:

5 0
3 years ago
Read 2 more answers
11. The golden rule of safe driving is: A. Always drive at the posted speed limit B. Never drive while physically or mentally im
Nonamiya [84]

Your correct answer is A. Always drive at the posted speed limit.

While B. and C. are logically also correct, I wouldn't call them the "golden" rules. Following A. can help you avoid B. to make matters better, hehe.

3 0
3 years ago
This might sound crazy! But please help.
aliya0001 [1]

Answer:

You Probably should’nt do that

Explanation:

8 0
2 years ago
Other questions:
  • "Simon Says" is a memory game where "Simon" outputs a sequence of 10 characters (R, G, B, Y) and the user must repeat the sequen
    10·1 answer
  • what is the opportunity cost of buying a $.75 soda everyday at school for 3 years instead of drinking water ? assume you are in
    10·2 answers
  • Sukant’s professor asks her to take over his online class while he is away because she is an effective digital communicator. Whi
    11·2 answers
  • Pls help me!!!!!!!!!!!!!
    5·2 answers
  • The calcCircleCircumf() method invoked within in the CircleStatsTester class is overloaded. Write the overloaded methods in the
    8·1 answer
  • Please help me the program c++
    15·1 answer
  • katniss dismisses effie's metaphor because, literally, she knows pearls cannot be created with pressurised coal,they come from w
    5·2 answers
  • Determine the distance between point (x1, y1) and point (x2, y2), and assign the result to points Distance. The calculation is:
    12·1 answer
  • Make a jingle about basic of photo editing<br>pls answer me asap​
    10·1 answer
  • Trademarks _____.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!