What will be the output of the following C# code?
class method1
{
public int fun(int m)
{
return( m++ % 10);
}
}
class Program
{
static void Main(string[] args)
{
int a = 23, b = 0, c;
method1 z = new method1();
c = z.fun (++b * --a % 2);
int d = (z.fun (c-- + --a));
Console.WriteLine(c);
Console.WriteLine(a++);
Console.WriteLine(d);
Console.ReadLine();
}
}
class method1
{
public int fun(int m)
{
return( m++ % 10);
}
}
class Program
{
static void Main(string[] args)
{
int a = 23, b = 0, c;
method1 z = new method1();
c = z.fun (++b * --a % 2);
int d = (z.fun (c-- + --a));
Console.WriteLine(c);
Console.WriteLine(a++);
Console.WriteLine(d);
Console.ReadLine();
}
}
A. -1, 22, 0
B. -1, 21, 1
C. 0, 22, 1
D. 0, 22, 0
Answer: Option B
Related Questions on Operators and Expressions in C Sharp
What does the modulus operator (%) do in C#?
A. Increments the operand by 1
B. Returns the quotient of a division
C. Performs multiplication
D. Returns the remainder of a division
Join The Discussion