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
An existing document that you use as a starting point for a new document; it opens a copy of itself, unnamed, and then you use t
masha68 [24]

Answer:  

The answer is "Template".  

Explanation:  

  • Templates are multi-designed documents for desktop publishing. These templates can be used to generate business cards, brochures, greeting cards, and other desktop documents.
  • There are several types of templates, that include mixing and matching components and provides a wizard to select objects from the list that gathers a list and provide a final result.
7 0
3 years ago
What is difference between RAM and ROM?
Lesechka [4]
Hi pupil here's your answer ::


________________________

RAM ::

● Data can be read and written on the RAM chip at any number of times.

● The operating system, application programs and the user data is stored in Ram only until the computer is powered on.

● Ram is a volatile memory that loses its contents when the computer is switched off.

● The size of RAM makes a difference in the processing, i.e. the bigger size of the RAM the greater is the speed of processing.

ROM ::

● Data can only be read from the ROM chip.

● Only system programs are stored in ROM. It can't be used to store user data and other programs.

● ROM is non volatile memory the data stored in ROM is permanent in nature.

● Size of the ROM has nothing to do with processing.


________________________

hope this helps. . . .
5 0
4 years ago
Which of the following is the best way to add a lengthy explanation to Excel data without being limited to cell sizes and restri
trapecia [35]

Answer:

B

Explanation:

Which of the following is the best way to add a lengthy explanation to Excel data without being limited to cell sizes and restrictions? A. Adding a chart object B. Adding an Access object C. Adding a Word object D. Adding an Excel object microsoft word

Answer: B

6 0
3 years ago
How many bits are used to direct traffic to specific services running on a networked computer?
Mars2501 [29]

Answer:

The correct answer is 16 bit.

Explanation:  

The main role of the transport layer provided the communication channel of the process which are running in a different host. When the information flows there is always traffic that is arisen but the transport layer aimed is that process will go at the correct node and received at the proper destination. The 16-bit number specifies that the process or node is running in the networked traffic.

3 0
3 years ago
Help please I would really appreciate <br>​
Dafna1 [17]

Answer:

the answer is address bar

3 0
3 years ago
Read 2 more answers
Other questions:
  • When an instance of a class, or object, is specified as a parameter to a method, a reference to the said object is passed to the
    15·1 answer
  • Find an element inside a div using javascript
    12·1 answer
  • The program needs a Frisbee Golfer class.
    15·1 answer
  • 4. A friend knows you are taking a technology class in college and asks you how a hard drive works. In your own words, describe
    6·1 answer
  • What additional information could you add to a sketch to provide other team members with a more accurate design drawing?
    9·1 answer
  • On a camera,what does focus tracking do?
    6·1 answer
  • What network problems can be solved on your<br> end?
    13·2 answers
  • (Giving brainliest to best answer, don't make an answer if you don't know or its jumble)
    11·2 answers
  • Write the issue related to the cyber ethnic. ​
    7·2 answers
  • PLEASE HELP ASAP what is the main purpose of electronic speed controller ESC
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!