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 / mahavishnu

class Demo{
void check()
{
int a=0;
for(int i=1;i<=10;i++)
{
int b=i*i;
a=a+b;
System.out.println(a);
}
}
}
public class Newdemo
{
public static void main(String[] args)
{
Demo d=new Demo();
d.check();
}
}

Is This Answer Correct ?    2 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a function which accepts a sentence as input parameter.Each word in that sentence is to be reversed. Space should be there between each words.Return the sentence with reversed words to main function and produce the required output. for eg:- i/p: jack jill jung kill o/p: kcaj llij gnuj llik

1745


1.what is the vesition managment.

1672


Difference between debugging, running, executing of an application

3477


iam confused among testing ,.net and java. can anybody help me.

1567


Can i please VHDL code for D-Latch with clear input ?? (HINT: Set up a “Process” with appropriate sensitivity list to get the desired D-Latch with Clr working.) Inputs and Outputs: entity Lab4b is Port ( Clr, Clk, D : in STD_LOGIC; Q : out STD_LOGIC); end Lab4b;

981






how to stop execution of step 3 in a job mainframe

1704


Please describe an example where you used object orientation in one of your programs.

1481


suppose we have ten members of a physical file but we want the output of last 5 members only.how to achieve that?

1486


public static void main(String args[]) describe it

1566


Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers.

778


kindly send interview materials

1303


why we need to take u?

1667


we create a pf with 3 fields.2 is defined as keyfields.we lock it with alcobj command.how we find out whether the file is locked or not?is it dspfd??/

1606


what is the basic and unique feature of dotnet

1708


through which algorithm does the garbage collector works? how the garbage collector will understand that the object will going to be deleted?

2064