write a program to find the sum the result(s) s=(1+2+3.... n) /n by using for loop
Answers
Answered by
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