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 it's important for designers to consider the environmental impact of a<br> product they design.
Aloiza [94]

Answer:

Kindly check explanation

Explanation:

The environment is our abode which aids the continued survival and growth of plant, animals and humans. The most important components and natural resources which are neceaaaarybto dwell and survive are all waht a makes up an enviromment. The energy derived from the sun aids power generation, plant growthbduring photosynthetic activities which is rewired to produce crops and feed us. The air we breathe are all a part of our enviromment. Therefore, such environment which provides a canvas or platform for our existence must be greatly cared for and no technological innovation, project or design must be allowed to impact negatively on the enviromment. Thus the need for impact assessment of systems in other to ensure that our abode isn't threatened.

4 0
3 years ago
Sharon is responsible for the security on web applications. She’s looking to see if all applications have input validation. What
LiRa [457]

Answer:

Options Include:

<em>A) Server-side validation </em>

<em>B) Client-side validation </em>

<em>C) Validate in trust </em>

D) Client-side and server-side validation

<em>Client-side and server-side validation is Correct</em>

Explanation:

The best option is to validate the client side with the server side. Using these together would provide the best testing option for Sharon.

<em>This keeps user feedback instantly without wasting postbacks while also protecting against JavaScript disabled users. That's how the validation controls for ASP.NET operate. </em>

This is definitely not over-engineering as there are risks of using one without the other.

Individual validation on the server side and individual validation on the client side are both incorrect. Trust validation is not a form of validation.

4 0
3 years ago
What element allows text to be displayed in italics, which means the words are slanted to the right?
Igoryamba

Answer:

the answer is the italic element

3 0
2 years ago
What is the appropriate guidelines to create and manage files
Maurinko [17]

Answer:

1. Do not copyright

2. Nothing illegal

3.Do not put personal info

Explanation:

3 0
3 years ago
Question 55 :You use a computer named Wkst1 on a TCP/IP network, which is installed with an application that uses UDP to send a
liubo4ka [24]

Answer:

The protocol will drop the packets

The application will automatically re-transmit the packets

Explanation:

Based on design, the routers will drop the packets as allowed by the Internet Protocol, due to the collision that resulted from the router being busy and the network is congested or that the packet is corrupt as indicated by the check sequence of the Ethernet frame or the IPv4 header checksum

Given that the application uses User Datagram Protocol (UDP) which does not allow recovery of lost packets, but have their defined methods of overseeing lost packets, as such the application will re-transmit the packet.

4 0
2 years ago
Other questions:
  • Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending whe
    12·1 answer
  • Why is timbre an important musical element?
    7·2 answers
  • Which of the following expansion ports would be used to enable transfer of power, data, and video to peripheral devices on an Ap
    7·1 answer
  • When using vlookup, the _____argument is optional?
    8·1 answer
  • Complete a graphic organizer to explain the responsibilities of a borrower
    14·1 answer
  • A ____ is a device that interconnects two or more workstations in a star-wired bus local area network and immediately retransmit
    9·1 answer
  • Answer the following questions: • What is the source of the user’s request? Can a technical solution solve his problem? Perhaps
    10·1 answer
  • What is metrical task system algorithm?? and can we use that in online shopping project??
    11·1 answer
  • Cuando se creo argentina​
    11·1 answer
  • I need help pleaseeee
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!