Write an Algorithm to find the sum of first ten even numbers. Also make its Flowchart.
Answers
Answered by
12
Hope it help you.
Mark me as brainliest and follow me to get instant correct answers.
Attachments:
Answered by
0
class first_ten_even_num {
public static void main(String[] args) {
System.out.println("Sum of first 10 even numbers is: \r\n");
int total_sum = 0;
for (int i = 0; i < 20; i++) { // 20 is written because in 20 consecutive number there will be half even
// and half odd numbers.
// And this series is starting from 0 to n.
if ((i % 2) == 0) {
total_sum += i;
}
}
System.out.println(total_sum);
}
}
Flowchart:
Attachments:
Similar questions