Question: Which of the following is used to create a conditional statement in C#?
A
B
C
D
if
B
for
C
while
D
switch
Note: The if statement is used to execute code based on a condition.
int x = 10; if (x > 5) Console.WriteLine("Greater"); else Console.WriteLine("Smaller");
for (int i = 0; i < 3; i++) { if (i == 1) continue; Console.WriteLine(i); }
switch (x) { case 1: break; default: break; }
int num = 2; switch (num) { case 1: Console.WriteLine("One"); break; case 2: Console.WriteLine("Two"); goto case 1; case 3: Console.WriteLine("Three"); break; default: Console.WriteLine("Default"); break; }