본문 바로가기
(Pre-class)

For - If exercise

by coramdeo643 2025. 4. 3.
// print the counting of the 5 times numbers from 1 ~ 100
int count = 0;
for(int i = 1; i <= 100; i++) {
  if(i % 5 == 0) {	
    System.out.println(" i : " + i);
    count++;
  } // end of if
} // end of for
System.out.println("count : " + count);
// print as following :
000
111
222

for (int a = 0; a < 3; a++) {
  for (int i = 0; i < 3; i++) {
    System.out.print(a);
  } // inner of for
System.out.println();
} // out of for

'(Pre-class)' 카테고리의 다른 글

Nested for loops exercise  (0) 2025.04.03
Do-while loop?  (0) 2025.04.03
Break and Continue?  (0) 2025.04.02
While loop?  (0) 2025.04.02
For Loop?  (0) 2025.04.01