convert the following into do while loop..
Attachments:
Answers
Answered by
2
public class OddEvenSum {
public static void main(String[ ] args) {
int i = 1;
int sumEven = 0, sumOdd = 0;
do {
if (i % 2 == 0)
sumEven += i;
else
sumOdd += i;
} while (i <= 50);
System.out.println("Sum of even numbers is - " + sumEven);
System.out.println("Sum of odd numbers is - " + sumOdd);
}
}
Similar questions