sketchub icon

for

Arsein___App
4 Likes
2 Comments
31 Downloads

What's new

None

Screenshots

About

A for loop allows you to repeat a block of code a certain number of times. This loop is available in many programming languages, though the syntax might differ slightly.

Here's a simple example of a for loop in Python:

for i in range(5):
    print(i)

This code will print the numbers 0 to 4.

A similar example in Java:

String words = "hello";
for (char i : words.toCharArray()) {
    System.out.println(i);
}

This code will also print the numbers 0 to 4.

In both examples, the for loop initializes the variable i to 0, then increments it by 1 each time the loop runs, until it reaches 5 (or less than 5 in Java)

©2024 Sketchub | User Policy