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
sample and simple coding where we get?
Find out the roles which gives access to all tables in SAP? Thanks in advance.
public static void main(String args[]) describe it
I'm new to ABAP. What is Module pool in SAP?
How to change the color of a cell or a row in a datagrid on mouse hover using javascript/.net
the systematic access of small computers in a distributed data processing system is referred as?
Which language they use during interview?
Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 1 number. Find the missing number
how much fee for deccan soft institute .how to block seat for sandeep sir class reply soonnnnÂ
Hi can you please help for the following. I have a ASP.Net web page I want to print the whole page how is it possible? I want It in ASP also.Please send me the solutions dipankar.hazari@gmail.com . Thanks in advance.
When we have two versions of the dot net installed how does the compiler know which version of DLL it has to select to an application.
Which CRM is better to opt, Sebiel CRM or Salesforce CRM or sap CRM? which institute is best one in hyderabad
hi all, i need ur help in preparing a sql which performs scd2, i mean i have a scd2 mapping i need a sql which can give me same result as scd2 mapping, SRC table: cust_no, loc 01 abc 02 xyz TGT table: pm_ky cust_no loc current_flag 1 01 abc Y 2 02 xyz Y cust 1 has changed his loc to xyz then it loads into TGT table as below, pm_ky cust_no loc current_flag 1 01 abc N 2 02 xyz Y 3 01 xyz Y i need sql to get the above result, hope got me question, Any suggestion will be appreciate.. thanks, Vinod
Given an array of size n, containing every element from 1 to n+1, except one. Find the missing element.
how to work search engine? plz detail answer me.