Write a program to calculate the following
i want a Java program for this condition
1+4+9+16+….+100

Like this (1^2+2^2)

Hint use function pow(a,b)

Answer Posted / sugumar

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ImprtntPrgrms;

/**
*
* @author user
*/
public class series {



public static void main(String args[]){
int i=1,sum=0;
series obj = new series();
for(i=1;i<=10;i++){
sum=sum+(i*i);

System.out.println("Values="+i*i);

}
System.out.println("Sum"+sum);

}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is Negative testing?

1489


What is the merger sort principle and its time complexity.

627


9.Difference between even and odd signals?explain with the diagram?

2944


code for connection from windows forms to sql server

1697


When we have two versions of the dot net installed how does the compiler know which version of DLL it has to select to an application.

1418






What is test execution and when will we start execution please send me one example for this question

1415


1. Consider the following code in our example assembly language: ; an example bit of assembly code ROOT: W FATHER FATHER: W SON1 W SON2 SON1: W NIL W NIL ; ---------------------- SON2: W GRANDSON W NIL GRANDSON: W NIL W NIL NIL = 0 Assemble this code carefully following the two pass model, and show the symbol table at the point marked by the dashed line during each pass.

1807


what are resources in case of Threads

1658


What is abstract Method i want the exact definition and is there any possibility to declare class as abstract without any abstract methods in that class?If it is possible then tell me why and how?

1461


what are importance in problem tracking

1609


what is the use of occurs 10 or (any number) in the internal table declaration with header line.

1460


Is class is a abstract datatype in java?

1440


what is the work of 1tier,2tier,&ntier? Plz Explain it!

2022


How to call dll API sub routine in VB Form.

1896


WS-NUM PIC S9(05)V(02) SIGN TRAILING SEPARATE MOVE '0050000+' TO WS-NUM The value stored is 00500,00+ MOVE '0050000-' TO WS-NUM Then what is the value will be stored in WS-NUM? Am getting '-00500,00'.....>>> What should I declare to WS-NUM so that I can get correct values for both + & - signs.

1838