Assiut University Faculty of Computers & Information 3th Level
Assiut University Faculty of Computers & Information 3th Level
Assiut University Faculty of Computers & Information 3th Level
1
12. Which of the following mathematical operators can be used to concatenate strings:
A / B *
C + D -
13. In the C# statement x = a + 5 - b:
a and b are ________
a + 5 - b is ________
A terms, a group B operators, a statement
C operands, an expression D operands, an equation
14. Write the output of the following program:
static void Main (){
unsigned int i = 10;
while (i-- >= 0)
cout << i << endl;
system("pause");
return 0;
}
A 10 9 8 7 6 5 4 3 2 1 0 B infinte loop
15. Write the output of the following program:
static void Main(string[] args){
int a, b, c;
for (a = 0; a < 1; a++)
for (b = 0; b <3; b++)
for (c = 0; c <3; c++)
if (a != b && a != c && b != c) Console.WriteLine ("{0}{1}{2}",a , b , c);
}
A 012 B 012021
021
16. Write the output of the following program:
static void Main (){ int x=7,y=8;
Console.WriteLine((x & y));
if((x + y) == (x | y))
Console.WriteLine("NotOK");
else
Console.WriteLine("OK");return 0;}
A 0 B 0
NotOk OK
17. Write the output of the following program:
static void Main (){int a = 12, b = 12, c = 1;
c = (a - b)>0 ? 10 : 12;
Console.WriteLine("The value of c is: {0}",c);}
A The value of c is: 10 B The value of c is: 12
18. Write the output of the following program:
static void Main (){
int a = 5, b = 6, c = 7;
if (a > b)
if (b < c)
c = a;
else
2
c = b;
Console.WriteLine("c= {0}",c); }
A C=7 B C=6
19. Write the output of the following program:
static void Main () {
int number = 1;
while (number <= 3) {
Console.WriteLine("{0} squared is {1}", number, SQR((++number)));
}}
static int SQR(int x) { return (x) * (x); }
A 2 squared is 4 B 1 squared is 4
3 squared is 9 2 squared is 9
4 squared is 16 3 squared is 16
20. Write the output of the following program:
static void Main () {
int number = 1;
while (number <= 3) {
Console.WriteLine("{0} squared is {1}", number, SQR((number++)));
}}
static int SQR(int x) { return (x) * (x); }
A 1 squared is 1 B 0 squared is 1
2 squared is 4 1 squared is 4
3 squared is 9 2 squared is 9
21. Write the output of the following program:
static void Main(string[] args) {
int[] arr = new int[10];
arrayMethod(ref arr);
Console.WriteLine(arr.Length);
}
static void arrayMethod(ref int[] a){
int[] b = new int[5];
a = b;
}
A 5 B 10
22. Write the output of the following program:
static void Main(string[] args) {
char[] asd = { 'A', 'B', 'C' };
string txt = "";
for (int a = 0; a < 3; a++)
for (int b = 0; b < 3; b++)
for (int c = 0; c < 3; c++)
if (a != b && a != c && b != c)
txt += asd[a].ToString() +asd[b].ToString() + asd[c].ToString();
Console.WriteLine(txt);
}
A ABCACBBACBCACBACAB B ABCACBBACBCACABCBA
23. Write the output of the following program:
static void Main(string[] args) {
int[] arr = new int[] { 1, 2, 3, 4, 5 };
Console.WriteLine(fun1(ref arr));
3
}
static string fun1(ref int[] array) {
for (int i = 0; i < array.Length; i = i + 2)
array[i] = array[i] + 10;
return (string.Join(",", array));
}
A 11,2,13,4,15 B 11,2,12,4,16
24. Write the output of the following program:
static void Main(string[] args){
int[] i = new int[0];
Console.WriteLine(i[0]);
}
A 0 B Exception
25. Write the output of the following program:
static void Main(string[] args) {
var stringValue = "Hello World!";
var stringValue2 = stringValue;
stringValue = "Hello Egypt!";
Console.WriteLine(stringValue2);
var array = new[] { 1, 2, 3, 4 };
var array2 = array;
array[0] = 99;
Console.WriteLine(array2[0]);
}
A Hello World! B Hello Egypt!
99 99
26. Write the output of the following program:
static int div(int a, int b = 5){
return (a + b);
}
static void Main(string[] args){
Console.WriteLine(div(120));
Console.WriteLine(div(120, 4));
}
A 124 B 125
125 124
27. Write the output of the following program:
static void Main(string[] args){
var v = "Hello World!";
v = 10;
System.Console.WriteLine(v);
}
A Compile error B Run time error
28. Write the output of the following program:
static void Main(string[] args){
int[] Asd = { 1, 8, 3, 6, 2, 5, 9, 3, 0, 2 };
Value(Asd, ref Asd[0]);
Console.WriteLine("The return value is {0}", Asd[0]);
}
static void Value(int[] asd, ref int Val){
4
for (int i = 1; i < asd.Length; i++) {
if (asd[i] > Val)
Val = asd[i];
}
32. Write the output of the following program when the input is 5:
static void Main(string[] args){
int N = int.Parse(Console.ReadLine());
int first = 0, second = 1, next;
for (int i = 0; i < N; i++){
if (i <= 1)
next = i;
else{
next = first + second;
5
first = second;
second = next;
}
Console.Write("{0} ", next);
}
}
A 11235 B 01123
33. Write the output of the following program when the input is 5:
static void Main(string[] args){
int n = int.Parse(Console.ReadLine());
for (int i = 1; i <= n; i++){
for (int j = 1; j <= i; j++){
Console.Write("{0}{1}", j, " ");
}
Console.WriteLine();
}
}
A 1 B 1
1 2 1 3
1 2 3 1 3 5
1 2 3 4 1 3 5 7
1 2 3 4 5 1 3 5 7 9
34. Write the output of the following program when the input is 5111:
static void Main(string[] args){
int N = int.Parse(Console.ReadLine());
int sum = 0;
while (N != 0){
sum += N % 10;
N = N / 10;
}
Console.WriteLine(sum);
}
A 88 B 8
35. Write the output of the following program:
static void Main(string[] args)
{
Console.Write ("*\n**\n***\n****\n*****\n");
}
A * B *****
** ****
*** ***
**** **
***** *