+ 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 Réponses
+ 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.