Computer Science, asked by ravendrasrivastava90, 2 months ago

please tell this answer class 9 icse.​

Attachments:

Answers

Answered by anindyaadhikari13
4

Required Answer:-

Question:

Write a Java program to display the sum of the series.

S = 1*2 + 2*3 + 3*4 + . . . . . + 19*20

Solution:

Here comes the program.

public class Sum {

 public static void main(String[] args) {

     int i=1, s=0;

     for(i=1;i<=19;i++)

        s+=i*(i+1);

     System.out.println("Sum: "+s);

 }

}

Algorithm:

  1. START.
  2. Declare S = 0
  3. Iterate a loop in the range i = 1 to 19.
  4. Add the value of i(i + 1) to the sum after each iteration.
  5. Display the sum.
  6. STOP.

Refer to the attachment for output ☑.

Attachments:
Similar questions