Computer Science, asked by WhOH, 16 days ago

1^2+2+3^2+4+5^2+6+7^2+8+9^2+10

Write a program in Java to print the sum.

Answers

Answered by anushadaram
0

this is the answe for given question

Attachments:
Answered by SherlyPhebe
0

Answer:

public class Main

{

    public static void main(String[] args)

    {

int s=0;

for(int n=1;n<=10;n++)

s=(n%2==0)?s+n:s+n*n;

System.out.println(s);

    }

}

Similar questions