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
If given program is executed, what will be output?
iogann1982 [59]

Answer:

16 22 399 214 351

Explanation:

es 1 .22 399 480

3 0
2 years ago
What are the best 3 xbox 360 games ?​
Andru [333]
Halo
GTA
Call of duty
5 0
3 years ago
Read 2 more answers
What statement would you use to assign the value 32 to the variable cheeses?
bezimeni [28]

Answer:

Statement to assign 32 to variable cheeses.

cheeses=32;

Explanation:

To assign any value to a variable in any programming language, we use "="operator.First declare a variable "cheeses"of type "int" in this case.Then assign 32 to variable "cheeses" with the help of "=" operator.After assigning 32 , variable will store 32 in it.

Implementation in c++.

#include <bits/stdc++.h>

using namespace std;

int main()

{

int cheeses;

cheeses=32;

return 0;

}

6 0
3 years ago
PLEASE GET THE RIGHT ANSWERS AND HELP MEEE
Afina-wow [57]

Answer: #1 is A

Explanation: Parents often monitor what their child is doing online because online activities can be threatening and sometimes dangerous to a child's life, depending on what they come across on the web. just a hunch

4 0
3 years ago
Read 2 more answers
When making programmed decisions, the information needed to make this decision is __________, and the problem is highly structur
pentagon [3]

Answer:

readily available

Explanation:

The information needed to make this decision is readily available. That is because such decisions have been made countless times that strict guidelines have been created to handle any similar future decisions. These strict guidelines are organized as a sequence of events that must be followed accordingly and are always available for when the situation arises. Examples of this would be "What to do when a machine breaks?" or "What constitutes firing an employee?"

7 0
3 years ago
Other questions:
  • The World Wide Web consists of interconnected computer networks throughout the world that everyone can use. True or False
    13·2 answers
  • Given the following adjacency matrix, what is the approximate rank vector after one iteration of the power iteration method (use
    10·1 answer
  • Consider the following classes: public class A { private int myNum; public A(int x) { myNum = x; } public int getNumber() { retu
    11·1 answer
  • Smoking is a REALLY good example of a choice that can have negative effects on the smoker's health, AND the well-being of others
    9·1 answer
  • The family size bottle of sunscreen holds 121212 fluid ounces (\text{fl oz})(fl oz)(, start text, f, l, space, o, z, end text, )
    12·1 answer
  • The World Wide Web is full of unstructured data. Search engines like Google, Bing and Yahoo have been doing a good job of allowi
    5·1 answer
  • Which is technologically backward country? Options United States U K CHILE INDIA
    14·1 answer
  • In order for a fault-block mountain to form, a ______ must take place along a fault line and one side must be ________.
    11·1 answer
  • Write a program to accept 10 different whole number from the user and store them in a
    11·1 answer
  • Define a new class Fighter that inherits from Spaceship. Add a variable property weapon that defaults to an empty string and a v
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!