Write the code that adds the integer numbers 1 through 10 Pr

Write the code that adds the integer numbers 1 through 10. Print the sum as it is being generated in the loop and at the end of the program.

Note: this is java programming

Solution

Answer:

import java.util.*;
import java.lang.*;
import java.io.*;

class Addnum
{
public static void main( String args[] )

{
int x;   
int sum=0;
for(x=1; x<=10; x++)
{
sum +=x;
}

System.out.print( \"the sum is \"+ sum );
}
}

output:

the sum is 55

Write the code that adds the integer numbers 1 through 10. Print the sum as it is being generated in the loop and at the end of the program. Note: this is java

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site