Computer Applications
Write a program in Java to find the sum of the given series:
(1*2) + (2*3) + …… + (19*20)
Java
Java Iterative Stmts
ICSE 2008
44 Likes
Answer
public class KboatSeries
{
public static void main(String args[]) {
int sum = 0;
for (int i = 1; i <= 19; i++)
sum += i * (i + 1);
System.out.println("Sum = " + sum);
}
}
Variable Description Table
Program Explanation
Output
Answered By
16 Likes
Related Questions
Write a program in Java to find the sum of the given series:
(1/2) + (2/3) + (3/4) + …… + (19/20)
Write a program to input a number and count the number of digits. The program further checks whether the number contains odd number of digits or even number of digits.
Sample Input: 749
Sample Output: Number of digits=3
The number contains odd number of digits.Write a program in Java to find the sum of the given series:
2 - 4 + 6 - 8 + …… - 20
Write a program to input a number and display the new number after reversing the digits of the original number. The program also displays the absolute difference between the original number and the reversed number.
Sample Input: 194
Sample Output: 491
Absolute Difference= 297