In: Computer Science
Using a “for loop” print all even numbers in range from 1 to 1000. Also, please count and print how many even numbers you have found.
Hello here is the answer ( code ) to this question.
I have implemented this question in java. Hope it helps.
public class Main {
   public static void main(String[] args) {
      
      
       int limit = 1000;
       int count = 0;
      
       System.out.println("Even numbers
between 1 and 1000 are: ");
      
       for(int i=1; i <= limit;
i++){
          
          
           if( i % 2 ==
0){
           count++;
          
    System.out.print(i + " ");
           }
          
          
       }
  
   System.out.println("\n The total numbers found are : "
+ count);
   }
}