Hi ,
Why does this code not work?
i starts with value 1 => 1%2 is not 0 so it should execute return "odd". In any case, a return should be executed. No?
Thanks
C#
tatic void Main()
{
Console.WriteLine(test());
}
static string test()
{
for (int i = 1; i< 10; i++)
{
if (i % 2 == 0)
return "even";
else
return "odd";
}
}
Basem AlshabaniRank #3,323 · 432 reputationPosted Aug 22, 2021, 6:10 AM EDT
Basem AlshabaniRank #3,323 · 432 reputationPosted Aug 21, 2021, 10:37 PM EDT
Valerie MeunierRank #1,526 · 1K reputationPosted Aug 22, 2021, 4:19 AM EDT
Valerie MeunierRank #1,526 · 1K reputationPosted Aug 22, 2021, 8:30 AM EDT