Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

qtp 9.2 14 days demo version was expired.I uninstalled how to reinstall this again

2781


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)

1173


what is c sharp dotnet

2263


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?

2060


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.

5358


Find out the list of roles which gives access to GUI activities? thanks in advance

2133


Difference between HTML and DHTML?

2212


What is autocall macro and how to create autocall macro? what is the use of it?

2039


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.

1861


Which method protects back button to retrieve old value from previous page in Struts.

1851


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

3643


code for connection from windows forms to sql server

2227


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)

4742


when we use mantis? how learn mantis?

2180


what do u mean by tagging

2063