Write a for loop that prints, in ascending order, all the positive integers less than 200 that are divisible by both 2 and 3, separated by spaces.

2
Write a for loop that prints, in ascending order, all the positive integers less than 200 that are divisible by both 2 and 3, separated by spaces.

LANGUAGE: C++

CHALLENGE:

Write a for loop that prints, in ascending order, all the positive integers less than 200 that are divisible by both 2 and 3, separated by spaces.

SOLUTION:


for (int i=1; i<200; i++){
    	if ((i%2)==0 && (i%3)==0){
        	cout << i << " ";
	    }
}

2 comments

Add comment