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]
2 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]2 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]2 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
Iven an array temps of double s, containing temperature data, compute the average temperature. Store the average in a variable c
ale4655 [162]

Answer:

import java.util.Arrays;

import java.util.Scanner;

public class num1 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter length of the array:");

       int len = in.nextInt();

       double [] temps = new double[len];

       double avgTem;

       int k =0;

       double total = 0;

       for( k=0; k<temps.length; k++){

           System.out.println("Enter values for the array");

           temps[k]=in.nextDouble();

       }

       System.out.println("The Arrays contains the following values");

       System.out.println(Arrays.toString(temps));

       // Computing the average of the values

       for(k=0; k<temps.length; k++){

           total = total+temps[k];

       }

       avgTem = total/(temps.length);

       System.out.println("The average Temperature is: "+avgTem);

   }

}

Explanation:

  • Using Java programming language
  • Import the Scanner class to receive user input
  • Prompt User for the length of the Array, receive and store in a variable len;
  • Declare a new double array of size len double [] temps = new double[len];
  • Using a for loop, continually prompt user to enter values into the array
  • Display the values of the array using Java's Arrays.toString method
  • Use another for loop to add up all the elements in the arraay and store in the variable called total
  • Outside the second for loop calculate the average avgTem = total/(temps.length);
  • Display the average temp.
6 0
2 years ago
What is the quotient of 8.16 ÷ 100​
Natalka [10]

Answer:

0.0816

Explanation:

8.16 ÷ 100 = 0.0816 (Ans)

6 0
2 years ago
The autocorrect feature can automatically capitalize the first letter in the names of days. true false
Westkost [7]
The answer is that it is true
3 0
3 years ago
A network technician incorrectly wired switch connections in your organization's network. It effectively disabled the switch as
REY [17]

Answer:

The answer is D. Implement STP or RSTP.

Explanation:

STP (Spanning Tree Protocol) was built to serve as a remedy for network issues. Existing before switches were developed, it works as a substitute for a switch when a switch is wired incorrectly (as seen in the question) or when it fails. STP has two roles:

  1. To serve as an alternative when there is network failure or changes.
  2. To block out issues caused by loops on a network

RSTP (Rapid Spanning Tree Protocol) was built to optimize the standard STP. When there is a topology change, spanning tree convergence is much faster than the standard STP.

To prevent network failure in the future, STP or RSTP should be implemented.

5 0
2 years ago
Select the true statement about HTML. HTML is a language that is used to create Web pages. HTML tags tell a web browser when to
Alexxx [7]

Answer: HTML is a language that is used to create Web pages.

Explanation:

HTML (Hypertext Markup Language) simply refers to the code which is used for the structuring of a web page and its content. e.g the content can be structured by using images, in data tables or within a set of paragraphs.

Therefore, the correct statement about HTML is that HTML is a language that is used to create Web pages.

6 0
2 years ago
Read 2 more answers
Other questions:
  • ___ is code that runs when a specific event happens.
    7·1 answer
  • What is the maximum transmission speed for bluetooth v3 and v4 devices?
    12·1 answer
  • Given that String[] str has been initialized, to get a copy of str[0] with all characters converted to upper case, use the follo
    5·1 answer
  • Derek is working at the help desk when he receives a call from a client about an issue with the company’s email. The customer is
    11·1 answer
  • You have been hired by Beta Airlines to help them with their flight prices. You are to create a 10 x 10 2D array (also called a
    10·1 answer
  • Write a program that declares a constant named QUARTS_IN_GALLON which holds the number of quarts in a gallon (4). Also declare a
    8·1 answer
  • Write a program that use a switch statement whose controlling expression is the variable area code. If the value of area_code is
    12·1 answer
  • PLEASE HELP ASAP (answer is needed in Java) 70 POINTS
    15·1 answer
  • Modify the program you wrote for Chapter 6 Exercise 6 so it handles the following
    15·1 answer
  • What is output?<br> x = 2<br> y = 3<br> print (x * y + 2)<br> 4<br> 2<br> 8<br> 10
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!