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 / 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 |
Post New Answer View All Answers
qtp 9.2 14 days demo version was expired.I uninstalled how to reinstall this again
Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array. So 3 2 7 10 should return 13 (sum of 3 and 10) or 3 2 5 10 7 should return 15 (sum of 3, 5 and 7)
what is c sharp dotnet
Write code to read the records from a file and load any array of size 99?make sure that you take care of all the error conditions?
I HAVE DONE TESTING TOOLS COURSE,NOW I AM FRESHER,I AM NOT GETTING ANY CALLS,I WANT TO DO THE PROJECT ,WHERE I HAVE TO MEET TO DO THE PROJECT,I AM GOING WITH FAKE EXPERIENCE,SO WHAT I HAVE TO DO.
Find out the list of roles which gives access to GUI activities? thanks in advance
Difference between HTML and DHTML?
What is autocall macro and how to create autocall macro? what is the use of it?
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.
Which method protects back button to retrieve old value from previous page in Struts.
For a binary tree with n nodes, How many nodes are there which has got both a parent and a child?
code for connection from windows forms to sql server
Display names and numbers of employees who have 5 years or more experience and salary less than Rs.15000 using array of structures (name, number, experience and salary)
when we use mantis? how learn mantis?
what do u mean by tagging