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
algol [13]
3 years ago
12

Write a while loop that adds the first 100 numbers (from 1 to 100) together. To do so, use a while loop that continues while the

condition of cur_num being less than or equal to stop_num is True. Inside the loop, it should add cur_num to the running total variable, and also add 1 to cur_num. Make sure to check at the end that the value of total reflects the total summation.

Computers and Technology
2 answers:
Anettt [7]3 years ago
6 0

Answer:

cur_num = 0

stop_num = 100

total = 0

while cur_num <= stop_num:

   total += cur_num

   cur_num += 1

print(total)

Explanation:

Initialize the variables

Initialize a while loop that iterates while cur_num is smaller than or equal to stop_num

Add the cur_num to total in each iteration to calculate the total

Increase the cur_num at then end of each iteration to control the loop

When the loop is done, print the total

Andreas93 [3]3 years ago
6 0

Answer:

I am writing JAVA and C++ program. Let me know if you want the program in some other programming language.  

Explanation:

JAVA program:

public class SumOfNums{

public static void main(String[] args) { //start of main function

int cur_num   = 1; // stores numbers

int stop_num= 100; // stops at this number which is 100

int total = 0; //stores the sum of 100 numbers

/* loop takes numbers one by one from cur_num variable and continues to add them until the stop_num that is 100 is reached*/

while (cur_num <= stop_num) {

 total += cur_num; //keeps adding the numbers from 1 to 100

//increments value of cur_num by 1 at each iteration

 cur_num = cur_num + 1;}

//displays the sum of first 100 numbers

System.out.println("The sum of first 100 numbers is: " + total); }}  

Output:

The sum of first 100 numbers is: 5050

C++ program

#include <iostream> //for input output functions

using namespace std; //to identify objects like cin cout

int main(){     //start of main() function body

int cur_num   = 1; // stores numbers

int stop_num= 100; // stops at this number which is 100

int total = 0;//stores the sum of 100 numbers

/* loop takes numbers one by one from cur_num variable and continues to add them until the stop_num that is 100 is reached*/

while (cur_num <= stop_num) {  

//keeps adding the numbers from 1 to 100

//increments value of cur_num by 1 at each iteration

 total += cur_num;

 cur_num = cur_num + 1; }  

//displays the sum of first 100 numbers

cout<<"The sum of first 100 numbers is: "<<total; }

The output is given in the attached screen shot.

You might be interested in
Levi wants to run 5 commands sequentially, but does not want to create a shell script. He knows that each command is going to ta
disa [49]

Levi can use the bash command to type all the commands on the same line to type one after the other character without requiring input.

<u>Explanation</u>:

  • He wants to run five commands. For one command it will take exactly 20 minutes. So it will take one hour forty minutes.
  • To type all of the commands on the same line Levi should use the bash command. For inserting the bash command Levi should use backslash \ as the last character of the line.
6 0
3 years ago
What are some of the major issues with geotagging? What concerns you the most?
Finger [1]

Answer:

Major issues with geotagging include the ability to pinpoint the exact location where a photo was taken, which raises privacy concerns.

What concerns me the most is when a geotag of an unsuspecting victim's location falls into the wrong hands.

Explanation:

Geotag -  A geographical tag that can attach to SMS text messages, media such as photos and images, etc. The Geotag is measured in the longitude and latitude at which the image or text message took place.

4 0
3 years ago
A(n) ______ is system software.
arsen [322]
System software<span> is a type of computer program that is designed to run a computer's hardware and application programs. If we think of the computer </span>system <span>as a layered model, the </span>system software<span> is the interface between the hardware and user applications</span>
7 0
3 years ago
You have a network with a subnet of 172.16.17.0/22. Which of the following is a valid host address?A. 172.16.17.1 255.255.255.25
Licemer1 [7]

Answer:

E. 172.16.18.255 255.255.252.0

Explanation:

Oh goodie, this is my home turf.

The answer is E) 172.16.18.255 255.255.252.0

This is because your subnet network ID includes mask \22, which means the ending with 255 255.255.252.0, which is standard for Class B. Only option E falls as an adequate host due to the network being 172.16.16 and broadcasting 16.19.

7 0
3 years ago
Question 11 of 20
asambeis [7]

Answer: A.) To convince your manager to use a new meeting organization tool

Explanation:

4 0
2 years ago
Other questions:
  • Custom parameters 1, 2 and 3 provide the same end value for all keywords. true or false?
    14·1 answer
  • When you lost important information how do you gain the information back?
    14·2 answers
  • A haiku is a three-line poem in which the first line contains five syllables, the second line contains seven syllables, and the
    12·1 answer
  • Which type of systems development is characterized by significantly speeding up the design phase and the generation of informati
    11·1 answer
  • Why is graphics important in multimedia application <br>​
    11·1 answer
  • REPORT THIS USER. HE'S SHOWING HIS YK WHAT TO EVERYONE INCLUDING ME. HIS ACCOUNT PROFILE IS IN THE PICTURE BELOW
    14·1 answer
  • What the central difference between negative and positive politeness?
    13·2 answers
  • What is a distinguishing feature of 5G mm Wave?
    9·1 answer
  • Should spreadsheets be used to keep an address list for holiday cards?<br> YES<br> ONO<br> Hurry pls
    13·1 answer
  • If you're connected to a switch and your NIC is in promiscuous mode, what traffic would you be able to capture
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!