I don't know why, but when I code this in C# Console App, its prints "211111111111~" and keep going (infinite loop), does anyone has tried it and got diff result?
I executed the following code, and "2" is displayed. Could you please explain why I should get a different value than 2?
static void Main(string[] args)
{
var printer = Printer(2);
Console.WriteLine(printer);
Console.ReadKey();
}
public static int Printer(int j)
{
for (var i = j; i < 0; i = Printer(i - 1))
{
Console.Write(i);
}
return j;
}
No, it's not. The for requires i > 0 to execute. So first enter the value 2, then subtract 1 to it's redundant call. The next one will subtract 1 again turning into 0, breaking the loop.
why? what's the point in saying this without any evidence? you're wrong and you could have checked this easily
by making unsupported comments like this you're just confusing people who are trying to learn
upvoted 2 times
...
...
This section is not available anymore. Please use the main Exam Page.98-361 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Oryza
5 months, 1 week agoOryza
5 months, 1 week agoBrob
8 months agomk_dyn365
1 year, 6 months agosathwik222222
1 year, 7 months agoHeicke
1 year, 2 months agomatt11
1 year, 3 months ago