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

how can we maintain the previous version scripts to new version.

1433


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

1476


I am work in it aompenei

977


WHat is execution in manual testing and when will we start execution and what language we use in execution

1488


How to call a C++ function which is compiled with C++ compiler in C code?

796






One boy has to climb steps. He can climb 1 or 2 steps at a time. Write a function that will returns number of way a boy can climb the steps. Int WaytoSteps(int n) (eg:- suppose number of steps is n=4 ,the function will return 5 (one-one-one-one ,one-one-two, one-two-one-,two-one-one, two-two)

3003


What is the use of Differ interface check box in Ship confirm?

1851


what will we require to build project with the help of oracle

1390


without selecting individually each field in Action Class from jsp,what is the best process to select as many as field at a time automatically from jsp page by using value object class.

1440


How to connect the .accdb database file of microsoft access to the Visual Basic 6.0 forms?

3709


what is client server & server? What r types of Joins? explsin it! which types of indexex in sql server? what is triggers?

1523


If u need any fake experience certificate in software side, contact me at: vikramyadhav@gmail.com

7848


How do i find out the number of parameters passed into function?

2221


what is log files in qtp what is use

1602


For a binary tree with n nodes, How many nodes are there which has got both a parent and a child?

3201