Computer Science, asked by chrisitanaumoh, 1 year ago

write an algorithm to print first ten even numbers

Answers

Answered by anitamitramadhu
1

//In_Java

class Even

{

public void main ()

{

int sum=0,i;

for(i=2; i<=20; i=i+2)

{

sum=sum+i;

}

System.out.println(sum);

}

}

Answered by hotelcalifornia
12

Answer:

1. Start

2. Declare a count variable (to keep track of number of even number printed)

3. Run a for loop from 1 to 100 (say 100)

4. Check if count has reached the number of even number printed as 10. If exceeds break  

5. Check if the current number in the loop is divisible by 2

6. If yes, then increment the count  and print the current number. Otherwise go to the next iteration.

7. Stop

Similar questions