The following questions may not bear any resemblance to past or future examination questions or cover all aspects of any exam. They relate only to course material and are for revision purposes only.
label1.Text = "c is less than 7";
label1.Text = "c is ";
label1.Text = label1.Text + "less than 7";
label1.Text = "Big deal";
case 0: label1.Text = "zero";
}
case 1: label1.Text = "one";
case 2: label1.Text = "two";
else: label1.Text = "Something else";
product *= c;
++c;
sum += z;
while (x <= 10);
x++;
if (x<10)
}
x++;
else
break;
while (x <= 10) {
total += x;
}
++x;
while (x<10)
sum += x;
x++;
label1.Text = label1.Text + " " + y;
}
y++;
for (x=0, x<100, x++)
label1.Text = label1.Text + " " + x ;
{
int result;
}
result = x+y;
{
sum = x+y;
}
{
int x=0;
}
label1.Text = x;
{
return x+y;
}
{
listbox1.Items.Add(x);
}
show(x);
return;
+ "orld\nTh" + "is is line " + 10/5 + '\n';
label1.Text = "x" + x + 'x' + "x + x" + x + x + (x + x);
x = Convert.ToInt32(textbox1.Text);
if (x>100)
label1.Text = "Big";
else
label1.Text = "Small";
x = Convert.ToInt32(textbox1.Text);
label1.Text = ((x>100) ? "Big" : "Small");
while (count<=10)
total += count++;
label1.Text = total;
string output = "";
for (i=1; i<=100; i++) {
output = output + "*";
}
if (i % 10 == 0) {
listbox1.Items.Add(output);
}
output = "";
while (x<=10) {
y = x * x;
}
listbox1.Items.Add(y);
total += y;
++x;
listbox1.Items.Add ("Total is: " + total);
if (x<10)
if (y>10)
label1.Text = "***";
else
label1.Text = "###";
label1.Text = "$$$"
Could this code be written in a clearer manner?
int x = rand.Next(1, 5);
switch(x) {
case 1: label1.Text = "1"; break;
}
case 2: label1.Text = "2"; break;
case 3: label1.Text = "3"; break;
case 4: label1.Text = "4"; break;
Is there a better way of writing this code?
listbox1.Items.Add (++x);
listbox1.Items.Add (x++);
listbox1.Items.Add (x);
int i;
for (i=0; i<10; i++)
list[i] = i+1;
for (i=1; i<10; i++)
list[i] = list[i-1] + list[i];
for (i=0; i<10; i++)
listbox1.Items.Add (list[i]);
001
002
:
010
011
:
098
099
100
00001
00004
00009
00016
:
10000
1 1 1
e = - + - + - + ...
1! 2! 3!
0 118
1 99
:
8 85
9 112
Do not store the 1000 random numbers.