C# Programming - Control Instructions
Exercise : Control Instructions - General Questions
- Control Instructions - General Questions
1.
What does the following C#.NET code snippet will print?
int i = 0, j = 0;
label:
i++;
j+=i;
if (i < 10)
{
Console.Write(i +" ");
goto label;
}
2.
Which of the following is the correct output for the C#.NET program given below?
int i = 20 ;
for( ; ; )
{
Console.Write(i + " ");
if (i >= -10)
i -= 4;
else
break;
}
3.
Which of the following statements is correct?
4.
What is the output of the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
{
public enum color
{ red, green, blue };
class SampleProgram
{
static void Main (string[ ] args)
{
color c = color.blue;
switch (c)
{
case color.red:
Console.WriteLine(color.red);
break;
case color.green:
Console.WriteLine(color.green);
break;
case color.blue:
Console.WriteLine(color.blue);
break;
}
}
}
}
5.
Which of the following is the correct way to rewrite the following C#.NET code snippet given below?
int i = 0;
do
{
Console.WriteLine(i);
i+ = 1;
} while (i <= 10);
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers