Which of the following code snippets are the correct way to determine whether a is Odd or Even int a; String res; if (a % 2 == 0) res = "Even"; else res = "Odd"; int a; String res; if (a Mod 2 == 0) res = "Even"; else res = "Odd"; int a; Console.WriteLine(a Mod 2 == 0 ? "Even": "Odd"); int a; String res; a % 2 == 0 ? res = "Even" : res = "Odd"; Console.WriteLine(res);

Comments and Answers (2)

Li

Li

need help, explain answer

Lavish

Lavish

please post an explanation

Avatar

{{SampleComment.userName || "Your Name"}} ~ {{SampleComment.userCity}}

{{SampleComment.commentValue || "Your Answer or Comment goes here...."}}