Write a Program to Sum of the Series of "1, 4, 9, 16..." in Java
import java.io.*;
class AddSeries
{
public static void main(String args[])
{
int i,j=0,sum=0;
for(i=1;i<=10;i++)
{
j = i *i;;
sum=sum+j;
for(i=1;i<=10;i++)
{
j = i *i;;
sum=sum+j;
System.out.println("\nSeris of entered integers = "+j);
}
System.out.println("\nSum of Series = "+sum);
}
System.out.println("\nSum of Series = "+sum);
}
}
Output:
Series of entered integer=
1
4
9
16
25
36
49
64
72
81
100
Sum of Series is=457
Series of entered integer=
1
4
9
16
25
36
49
64
72
81
100
Sum of Series is=457
Very helpful thank you
ReplyDelete