can the following loop be executed for(j=0;i=len-1;i>=0;i--;j++) and if yes please tell me how the execution procedure?
You really need to clarify your question. For instance, what language is this? (I've never heard of a language called "deep".)
If it's C, C++, Java, JavaScript, or one of the related languages, your syntax is slightly wrong (the first and last semicolons should be commas):
for (j = 0, i = len - 1; i >= 0; i--, j++) {
// Do something
}
...and yes, the body of the loop would run at least once if len
is greater than zero. (It will run as many times as the value len
, e.g., twice if len = 2
, three times if len = 3
.) Try it!
I don't know a single language where this would be a valid syntax. If you're talking about C, C++, C#, Java, JavaScript, PHP, or Objective C, no, it will not execute. Won't even compile. The following, however, will:
for(j=0, i=len-1; i>=0; i--, j++)
Note the commas instead of semicolons. On each iteration i will decrease and j will increase.