Computer Science, asked by prasannalenka26, 3 days ago

write a program to find the sum the result(s) s=(1+2+3.... n) /n by using for loop​

Answers

Answered by krish77761
1

Answer:

Sum is 15

Explanation:

class sum {

public static void main(String args[]){

int n = 5; //just taking n=5

int sum = 0;

int i=1;

do{

sum = sum + i;

i++;

}while(i<=n)

System.out.println("Sum is "+sum);

}

}

Similar questions