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
Rasek [7]
3 years ago
7

Write a for loop that computes the following sum: 5+10+15+20+...+485+490+495+500. The sum should be placed in a variable sum tha

t has already been declared and initialized to 0. In addition, there is another variable, num that has also been declared. You must not use any other variables.
Computers and Technology
1 answer:
Strike441 [17]3 years ago
6 0

Answer:

public class num9 {

   public static void main(String[] args) {

       int sum =0;

       int num =5;

       for(num =5; num<=500; num+=5){

           System.out.println(num);

           sum +=num;

       }

       System.out.println(sum);

   }

}

Explanation:

  • Declare and initialize the variables sum and num
  • Use a for loop with the condition for(num =5; num<=500; num+=5) Since the loop will increment by 5 and run from 5 to 500
  • Within the loop, add num to sum at each iteration
  • Print all elements on seperate lines
  • Outside the loop, print the final value of sum

Create a for loop

You might be interested in
Look at the following code.int x = 7;int *iptr = &amp;x;What will be displayed if you send the expression *iptr to cout ? What h
masha68 [24]

Answer:

The answer to the given question can be given as:

The value of *iptr is 7. and the value of iptr is dynamic.

Explanation:

In the c++ code, it is defined that x is an integer variable that assigns a value which is 7. Then we define a pointer variable that is *iptr. This variable holds an address of the x variable. When we print the value of the iptr variable. if we use the expression *iptr to print value of the pointer variable by cout that is used in c++ for pint values. so the value of the iptr is 7. If we use the expression iptr sent to cout so we show the address of the variable x. In the pointer, it manages the addresses of dynamically allocated so the address of the variable is changed on execution time.

4 0
3 years ago
What type of software repairs or improves a larger application that is already installed on a system?
earnstyle [38]

Answer:

<h2>Mapping</h2>

Explanation:

<h2>Hope it helps you</h2>
7 0
2 years ago
Read 2 more answers
Explain the difference between file and folder (in your own words)
denpristay [2]

Answer:

the difference is one is online and one is not

Explanation:

A file is usually what you find online. And a folder is what you put papers into.

7 0
3 years ago
Which of these methods can you use to insert a new row in a worksheet?
vodka [1.7K]

Answer:

I think It should be B

Explanation:

If wrong so please sorry

3 0
3 years ago
? Which console was the first to use CD-ROM storage? PlayStation Atari Jaguar PlayStation 3 Xbox 360
kaheart [24]

that is incorrect! Playstation is the correct answer

7 0
3 years ago
Other questions:
  • Describe the Say It, Cover It, Resay It method.
    14·2 answers
  • You can use Facebook's live feed tool to broadcast content as you post it
    8·2 answers
  • Schools are businesses that need to install software on a large number of computers can usually obtain a ______
    13·1 answer
  • Janelle went to update the last name for one of her group contacts. She double-clicked on the contact, changed the last name, an
    12·2 answers
  • 1. row a statement you submit to get paid for a product or service 2. spreadsheet software used by many business professionals t
    5·1 answer
  • Level of comfort that people feel
    10·1 answer
  • An inventory management system that goes beyond just managing inventory to act as a complete distribution system (including inve
    10·1 answer
  • Need help please asap
    9·1 answer
  • While all pages use HTML code, not all pages are written in
    15·2 answers
  • Pls help I will give points
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!