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
< DL Compact > tag is used for
How do you initialize a static member of a class with return value of some function?
what are stubs related to foxpro?
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.
Given: coordinates of rectangle-> left bottom and right top points. the rectangles create a hole.Find the maximum area of the hole. eg. 4 rectangles create a hole in between. find its area.
i am getting the error while compiling my cics program with including db2 dclgen member it is showing that ur dclgen member not including and all the host variables are undeclared
how to remove header and footer in jcl using sort utility
Can anyone send me NIC question papers alongwith answers on nidhi1485@yahoo.co.in? Urgently needed.. Thanks in advance
What is diffrent between Method and and function in c#
Define Form modules, Class modules and Standard modules
hi, all this is shoba m.c.a . i have learned abap but no oppurtunities right now as fresher , right now i want to learn any course on demand any one pls suggest me good course and institute in hyderabad
Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming
Any real time example of O2C process from taking order till creating invoice.
how we can know the funcions available in a class recording java?
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)