Computer Science, asked by gairikgupta, 7 months ago

write a program in java to find the sum of first ten even numbers.​

Answers

Answered by Anonymous
22
  1. Java Program :
  2. class sum_even. { public static void main() { int s=0,i,c=0; for(i=1;;i++) { if(i%2==0) { s=s+i; c=c+1; } if(c==10) break; } System.out.print("Sum : "+s); } } Output :
  3. Sum : 110. Note : Use the calculator and the notepad provided, at the top, to dry run the program.
  • hope it helps you..
Answered by kamblemanswi8
2

ANSWER::

To print the sum of the first ten even numbers in Java

Java Program :

class sum_even. { public static void main() { int s=0,i,c=0; for(i=1;;i++) { if(i%2==0) { s=s+i; c=c+1; } if(c==10) break; } System.out.print("Sum : "+s); ...

class sum_even. { public static void main() { int s=0,i,c=0; for(i=1;;i++) { if(i%2==0) { s=s+i; c=c+1; } if(c==10) break; } System.out.print("Sum : "+s); ...Sum : 110.

Note : Use the calculator and the notepad provided, at the top, to dry run the program.

Similar questions