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
Why did industrial revolution begin Britain?​
allochka39001 [22]

Answer:

Britain also happened to have a wealth of coal, iron, and other resources in a relatively small area, which would help kick-start the Industrial Revolution. Its growing Colonial Empire also provided a ready-made (and captive) market for surplus goods, providing further impetus for entrepreneurs and new industrialists

7 0
1 year ago
Read 2 more answers
Given three variables, a, b, c, of type double that have already been declared and initialized, write a statement that prints ea
mihalych1998 [28]

Answer:

The statement is written in Java.

  1. System.out.printf("%.5f %.5f %.5f",a,b,c);

Explanation:

Presume that there are three variable a, b and c which have already been declared and initialized with 4.014268319, 14309, 0.00937608 respectively.

To print each of the value with 5 digits to the right of the decimal point, we can use printf() method. We create a format specifier %.5f which is a placeholder of a floating point value. The .5 will specify five digits to the right of the decimal point.

We just create three similar format specifiers ( one for variable a, b, and c, respectively) and include them into printf() method. This will print the output as follows:

4.01427 14309.00000 0.00938  

6 0
3 years ago
What is the purpose of the 300 Log?
egoroff_w [7]

Answer:

The OSHA Form 300 is a form for employers to record all reportable injuries and illnesses that occur in the workplace, where and when they occur, the nature of the case, the name and job title of the employee injured or made sick, and the number of days away from work or on restricted or light duty, if any.

Explanation: brainliest plzzzz!

4 0
3 years ago
What type of information system would more be likely to be used by schools?
Masja [62]

Answer:

probably

informaition retreival

Explanation:

6 0
2 years ago
Andy wants to change some of the components in his old computer system.he had recently upgraded the motherboard and he now wishe
ladessa [460]

Looking at the images and the boxes, it goes like this;


To add external functionality of external backup, you would probably have something removable from the computer accessable. This means that the Optical Drive would add functionality of external backup, and the first tile goes there.


A processor is what does the general computations inside a laptop/desktop computer and processes information as the name implies. Upgrading the processor makes it go faster. The second tile would go to the processor.


The third one need no further explanation and would go to the Hard Drive, but just keep in mind that the Hard Drive stores all the information on your computer (i.e. Applications, Photos, etc.).


Hope this helps!

6 0
3 years ago
Read 2 more answers
Other questions:
  • You can join tables by using a condition in the ____ clause.​
    7·1 answer
  • A local government uses Short Message Service (SMS) text messages to alert local residents when roads are closed. Which of the f
    13·1 answer
  • Which data type is also called a binary object?
    9·2 answers
  • What is out put in a computer
    14·2 answers
  • Implement a function inValues() that asks the user to input a set of nonzero floating-point values. When the user enters a value
    7·1 answer
  • I really need this done Thank you!!
    6·1 answer
  • Which statement best describes the difference between a spreadsheet and a database?
    9·2 answers
  • Select the correct answer. Which sign or symbol will you use to lock cells for absolute cell reference?
    9·2 answers
  • Can anyone help my please
    10·2 answers
  • Typically, hybrid drives use SSD to store the operating system and applications and hard disks to store videos, music, and docum
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!