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
I am looking for selenium RC online Training in chennai. can any one tell me the best institute
what is the software to run the GSM gate opener program
Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fit" instead of the number and for the multiples of five print "Bit". For numbers which are multiples of both three and five print "FitBit".
why we use mantis? what u mean mantis in IT trends? addvantages of mantis?
Find out the roles which gives access to all tables in SAP? Thanks in advance.
Need guidewire related Documents(Interview Question/Tips/Best Practice/Dumps)
What is the meaning of client-server application. The purpose of Client-Server Application. with description.
how can we maintain the previous version scripts to new version.
how do we provide security for web services
Suppose we are doing 4 operations on database using service, first operation is successful but due to some reason remaining 3 operations are failed. I) is this transaction successful or not? ii) How can you give that error message to user?
Hi all... I had completed MSC(Computer) and had join the construction company based on sap.they want me to work on abap.but software company is totally different from construction company and they want me 2 grasp it as fast i can.i am finding it difficult.what should i do??????
How to call a C++ function which is compiled with C++ compiler in C code?
Define Form modules, Class modules and Standard modules
Which CRM is better to opt, Sebiel CRM or Salesforce CRM or sap CRM? which institute is best one in hyderabad
what are stubs related to foxpro?