+ 3
I don't understand why the answer is 120?
int foo=1; foo (int x=5; x<=50; x++) { foo*=x; for (int y=1; y<=5; y++) { if (x==y) {goto bar;} //goto=transfer control foo*=y; } } bar: Console. Write(foo) ;
3 Answers
+ 4
In the first for-loop:
foo Ă 5 = 5
Afterwards, in the second for-loop:
foo Ă 1 = 5
foo Ă 2 = 10
foo Ă 3 = 30
foo Ă 4 = 120
Then y is 5, so equal to x, thus both loops are canceled and as a result "go to" is executed and foo is printed, which is now 120.
+ 2
Could you share your code from Playground working?
+ 2
Yes it isâșïž I am working through my mistakes. And then I'm looking for articles on this topic.