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
Most switches enable you to use multiple nics for a single machine, a process called __________ or link aggregation.
scZoUnD [109]
Bonding.



Good luck! (:
5 0
3 years ago
Define the following functions related to spreadsheet:<br> a.Consolidate<br> b.Subtotal
Vikki [24]

Answer:

B I hope I'm right sorry if I'm wrong

4 0
3 years ago
Dani is paraphrasing from a paragraph of an article for a post on her blog. Which of the following strategies is least likely to
koban [17]
I would say A. She reads the entire paragraph, then rewrites it in her own words, and then checks to make sure her version is not too similar to the text from the article.


All the other ones are a little too obvious.


Hope this helps you, baii <33

4 0
3 years ago
Read 2 more answers
A user gets an ip address of 192.168.0.1 from the company network administrator. a friend of the user at a different company get
meriva
<span>Both computers are seen as having the same IP address externally. Your router will relay requests to the originating computer and the procedure used for this is Network address translation. However, if you were to try to communicating with your father's computer, you would use your internal addresses</span>
7 0
3 years ago
What should you always do to clean off tables
ikadub [295]
Wipe then off then spray them down then wipe off again
7 0
3 years ago
Read 2 more answers
Other questions:
  • What is the main purpose of broadcasting via satellite? A. To enable signal reception at night B. To convert analog signals to d
    5·1 answer
  • Is a term used to define those providers or hospitals that have the capabilities and processes in place to be actively use certi
    15·1 answer
  • You have compiled a new kernel using rpm. when you reboot, the new kernel is not the default selection on the boot menu. you use
    10·1 answer
  • Jerry’s managing a Google Search campaign and would like to improve the position in which his ads appear. He’s increased his bid
    15·1 answer
  • HELP PLEASE I WILL GIVE YOU 15 POINTS!
    8·1 answer
  • Write a Python program string_functions.py that defines several functions. Each function re-implements Python's built-in string
    9·1 answer
  • Cuales son las paginas web​
    12·1 answer
  • he degree of operating leverage is equal to: Group of answer choices FC / OCF. VC / OCF. 1 FC / OCF. 1 VC / OCF. 1 Picture FC /
    9·1 answer
  • Estoy haciendo codificación en este momento es tan confuso y no estar en la escuela es más difícil
    11·2 answers
  • What steps can you take to secure your private information?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!