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
what are the differences between CONS, LIST, and APPEND
what is the work of 1tier,2tier,&ntier? Plz Explain it!
what is delegate and delegation model give the real live example on delegate model
what is difference between kpo and it industry? that is in terms of work, package etc
Definition of Singleton Class? what is the Purpose of it? what is the advantage?
Hi All, Can any one please send me the difference between informatica 7i and 8i versions, Thanks in advance. vinod
what is woransient key word? how it is used in java
Hi I am Rathnam, How To Remove the duplicates with out using remove duplicate stage in the datastage
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
Any real time example of O2C process from taking order till creating invoice.
can any method return type may be constructor , or that method name allow
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?
I want to pass .pdf files as OlE Object to crystal report through VB6. Please any one guid me...
in IBM PC -AT.WAT AT REFERS TO?
1) How can u create the table?