# For loop for two variable at the same time

Can I use for loop for two variables as example show below at the same time?

for (int x = 0, y = 0; x < 10 && y < 10; x++, y++)

• @Nasser I won't mind any method but still at the same time increment in two variables, I was not able to do it..... – Muhammad Ali Jul 5 '19 at 12:50
• @Nasser It worked Thanks!! – Muhammad Ali Jul 5 '19 at 12:55
• More idiomatic in Mathematica would be something like Table[expression,{x,0,10},{y,0,10}]. Depending on what you're doing, you might use something other than Table, or even avoid the need for x and y by using something like Map. But you'll have to show us what you're trying to accomplish for us to help with that. – John Doty Jul 5 '19 at 12:56
• – rhermans Jul 5 '19 at 13:06

The For loop works just fine in the Wolfram Language, so I won't try to dissuade you from using it. Though I don't use it myself I've seen a resurgence in its use with the new compiler.

For[
x = 0;
y = 0
,
x < 10 && y < 10
,
x++;
y++;
,
Print[x, " and ", y]
]


results in this print:

0 and 0

1 and 1

2 and 2

3 and 3

4 and 4

5 and 5

6 and 6

7 and 7

8 and 8

9 and 9