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

what are the differences between CONS, LIST, and APPEND

5402


what is the work of 1tier,2tier,&ntier? Plz Explain it!

2521


what is delegate and delegation model give the real live example on delegate model

3325


what is difference between kpo and it industry? that is in terms of work, package etc

2090


Definition of Singleton Class? what is the Purpose of it? what is the advantage?

2142


Hi All, Can any one please send me the difference between informatica 7i and 8i versions, Thanks in advance. vinod

2037


what is woransient key word? how it is used in java

2442


Hi I am Rathnam, How To Remove the duplicates with out using remove duplicate stage in the datastage

1993


5. Which of the following can you do with DB2 Express- C? Query databases with SQL Query databases with XML using XQuery and XPath Use SQL in Xquery and Xquery in SQL All of the above

2616


Any real time example of O2C process from taking order till creating invoice.

2437


can any method return type may be constructor , or that method name allow

2138


1. How many jobs can we write in a single file? 2. How many maximum members can exist in a single partition data set(pds) in jcl?

2415


I want to pass .pdf files as OlE Object to crystal report through VB6. Please any one guid me...

3090


in IBM PC -AT.WAT AT REFERS TO?

1962


1) How can u create the table?

1933