Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Faculty of Computer Studies

M109
.NET Programming
Mid-term Examination – (MTA)
Fall Semester 2018/2019

Date: 14/11/2018

Number of Exam Pages:


(including this cover sheet)
(4) Time Allowed: (1.5) Hours

Instructions:
1. This exam consists of three parts ‫ هذا االمتحان مكون من ثالثة اجزاء يجب‬.1
you should answer all on the ‫االجابة على جميع االجزاء فى كراسة االجابة‬
separate answer sheet booklet. .‫المنفصلة مع ذكر رقم السؤال‬
2. Calculators without memory are ‫ يسمح باستخدام االلة الحاسبة التى ال تحتوى‬.2
allowed. .‫ذاكرة تخزين‬
3. Devices with a memory are not ‫ ال يسمح باستخدام اى آلة ذات ذاكرة تخزين مثل‬.3
allowed (example: mobile). .‫الهاتف المحمول‬
4. Total Mark: 60

M109 – MTA 1 of 4 Fall 2018/2019


Part I: Multiple Choice Question – MCQ 2 marks for each [10 Marks]

1) Which of the following is an 8-byte integer?


a. Char
b. Byte
c. Short
d. Long

2) Which of the following statement is TRUE about.NET framework?


a. It is an environment for developing, building, deploying and executing
only Web Applications.
b. It is an environment for developing, building, deploying and executing
Desktop Applications, Web Applications and Web Services.
c. It is an environment for developing, building, deploying and executing
only Windows Applications.
d. It is an environment for developing, building, deploying and executing
only Distributed Applications.

3) Which of the following is NOT an Arithmetic operator in C#.NET?


a. ++
b. %
c. *
d. /

4) Which of the following is the correct output for the C#.NET code snippet
given below?
Console.WriteLine(13 / 2 + " " + 13 % 2);

a. 6.5 1
b. 6.5 0
c. 60
d. 61

5) Which of the following statement is correct about the C#.NET code snippet
given below?
if (mo > 55 && no < 111)
a = 100;

a. The statement a = 100 will get executed if any one condition is True.
b. The condition no < 111 will be evaluated only if mo > 55 evaluates to
False.
c. The statement a = 100 will get executed if both the conditions are
True.
d. None of the above

M109 – MTA 2 of 4 Fall 2018/2019


Part 2: Short Questions – 5 marks each [25 Marks]

1. The following C# code contains syntax errors. Identify the errors and write the
correction opposite to each line of code. If there is no error in a line, write NO
ERROR.

CODE ERRORS
class Program
{
static void Mian(string[] args)
{
int a=100, b = =104
do
{
Console.WriteLine[b];
a--;
} while (a > 0)
Console.ReadLine();
}
}

2. What will be the output of the following code?

class Program
{ static void Main(string[] args)
{ int a, b, sum, subtr;
a = 100;
b = 20;
sum = a + b;
subtr = a - b;

Console.WriteLine("{0}\t{1}", "a+b", "a-b");


Console.WriteLine("{0}\t{1}", sum, subtr);
Console.ReadLine();
}
}

3. In the given set of code, write the correct ‘if-else statement’ to find the number
of positive numbers and negative numbers in a given array.

class Program
{ static void Main(string[] args)
{ int[] num = { 12, -10, 21, 8, 3, -2 };
int pos = 0, neg = 0;
for (int i = 0; i < num.Length; i++)
{
/* __________________ */
}
Console.WriteLine("Positive Numbers:" + pos);
Console.WriteLine("Negative Numbers:" + neg);
Console.ReadLine();
}
}

M109 – MTA 3 of 4 Fall 2018/2019


4. Explain conditional operator in C# with the help of an example.

5. Rewrite the following C# code using switch-case statement.

if (ch == 'a' || ch == 'A') countA++;


else if (ch == 'e' || ch == 'E') countE++;
else if (ch == 'i' || ch == 'I') countI++;
else if (ch == 'o' || ch == 'O') countO++;
else if (ch == 'u' || ch == 'U') countU++;
else Console.WriteLine("No vowel letter");

Part 3: Problem Solving Questions [25 Marks]

1. Write a C# program to allow the user to input 10 numbers. Count the number
of zero’s in the input and display the count. [15 marks]
Sample I/O

2. Write a C# program to calculate the sum of the series: 22+ 42+ 62+…….+ 122
[10 marks]
Output

End of Questions

M109 – MTA 4 of 4 Fall 2018/2019

You might also like