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)
Answers were Sorted based on User's Feedback
public class Power {
public static void main(String[] args) {
int b=2;
for(int i=1;i<=10;i++)
{
System.out.println(Math.pow(i,b));
}
}
}
| Is This Answer Correct ? | 7 Yes | 1 No |
Answer / sandeep
public class calc{
public int square(int a)
{
return a*a;
}
public static void main(String args[]){
int i=1,sum=0;
calc obj = new calc();
for(i=1;i<=10;i++)
sum=sum+obj.square(i);
System.out.println("answer ="+sum);
}
}
| Is This Answer Correct ? | 8 Yes | 3 No |
Answer / 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 |
Answer / mahavishnu
class Demo{
void check()
{
int a=0;
for(int i=1;i<=10;i++)
{
int b=i*i;
a=a+b;
System.out.println(a);
}
}
}
public class Newdemo
{
public static void main(String[] args)
{
Demo d=new Demo();
d.check();
}
}
| Is This Answer Correct ? | 2 Yes | 3 No |
Given a set. Write the pseudo code to get all the subsets for the given set. Eg. Input : {1,2} Output : (),(1),(2),(1,2)
3. . Explain the Cache memory? What is the advantage of a processor having more cache memory?
difference between mantis and other tools?
What is dialog programming?
kindly send interview materials
3.Give the formula for determine the range of the data type?
Who is the Best SAS/Clinical Trainer in Hyderabad
which worker is involved in all the phases of SDLC?
hai i am prasanna.I am MCA 2009 fresher.tell me about certifications.which certification helps me to improve my carrier and to get a technically oriented job ,which certification helps to get job faster.
What are the tasks performed by a Team Lead
To sorting array of 10 elements which sorting is best a)selection b)bubble c)tree sort
Given a arbitrary pointer to an element in a singly linked list?what is the time complexity for its deletion .