What will be the output of the following C# code?
static void Main(string[] args)
{
int n = 5;
int x = 4;
int z, c, k;
for (c = 1; c <= n; c++)
{
for (k = 1; k <= c; k++)
{
z = 3 * x * x + 2 * x + 4 / x + 8;
Console.Write(Convert.ToString(Convert.ToChar(z)));
}
Console.WriteLine("\n");
}
Console.ReadLine();
}
static void Main(string[] args)
{
int n = 5;
int x = 4;
int z, c, k;
for (c = 1; c <= n; c++)
{
for (k = 1; k <= c; k++)
{
z = 3 * x * x + 2 * x + 4 / x + 8;
Console.Write(Convert.ToString(Convert.ToChar(z)));
}
Console.WriteLine("\n");
}
Console.ReadLine();
}
A. A
AA
AAA
AAAA
B. A
AB
ABC
ABCD
C. A
AA
AAA
AAAA
AAAAA
D. A
BC
DEF
DEFG
Answer: Option C
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