Sei sulla pagina 1di 2

Examination Practice Set

1) Draw a parallelogram in a Windows Application using only the DrawLine Method


Graphics f = CreateGraphics();
Pen y = new Pen(Color.White);
int b = 400;
int a = 200;
for (int i = 100; i <= 200; i++)
{
f.DrawLine(y, a, i, b, i);
b++;
a++;
}
2) Draw a trapezoid in a Windows Application using only the DrawLine Method
Graphics f = CreateGraphics();
Pen y = new Pen(Color.White);
int b = 400;
int a = 200;
for (int i = 100; i <= 200; i++)
{
f.DrawLine(y, b, i, a, i);
b++;
a--;
}
3) Create a Console Application that displays all odd numbers from 0 to 100
int a = 2;
for (int i = 3; i < 53; i++)
{
Console.WriteLine(i-a);
a--;
}
Console.ReadKey(true);
4) Create a Console Application that displays all even numbers from 0 to a specified user input number x
int x;
Console.Write("Input value:");
x = int.Parse(Console.ReadLine());
int a = 2;
for (int f = 0; f <= x; f++)
{
Console.WriteLine(f+a);
a++;
}
Console.ReadKey(true);
5) Create a windows application that accepts an input string (a word) from the user and displays the word spelled in reversed order in
another textbox
6) Create a windows application that determines whether an input string (a word) is a palindrome or not. A palindrome is a word which
does not change even if you reverse its spelling, i.e. racecar. Try reversing the spelling of racecar, you’ll find that its reverse is still
racecar!
7) Create a console application that displays a flexible multiplication table. The user should be able to select the number with which to a
times table will be created. The times table does not start from 1 and ends with 12, rather the user should also be able to specify the
start and the end factors for the times table.
int x,y,z;
Console.Write("Input value of start:");
x = int.Parse(Console.ReadLine());
Console.Write("Input value of end:");
Console.Write("Input number of multiplicand:");
z = int.Parse(Console.ReadLine());
{
Console.WriteLine("{0}*{1} = {2}", z,f,z*f);
}
Console.ReadKey(true);
8) Create a console application that displays the first 50 prime numbers. A prime number is a numbers whose only factors are 1 and
itself, an example is 7.
9) Create a console application that accepts x number of integer user inputs and computes for the summation (total) of those input
numbers.
10)Create a console application that accepts x number of integer user inputs and computes for the average of those input numbers.
int x, y, z;
Console.Write("Input value of start:");
x = int.Parse(Console.ReadLine());

Console.Write("Input value of end:");


y = int.Parse(Console.ReadLine());

Console.Write("Input number of multiplicand:");


z = int.Parse(Console.ReadLine());
for (int a = x; a <= y;)
{
Console.Write(z);
Console.Write(" X ");
Console.Write(a);
Console.Write(" = ");
Console.Write(a * z);
Console.Write("\n");
a++;

Potrebbero piacerti anche