Download Mata Kuliah

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Mathematics of radio engineering wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Elementary mathematics wikipedia , lookup

Weber problem wikipedia , lookup

Transcript
Mata Kuliah : Algoritma dan Struktur Data 1 (Ilmu Komputer Kelas Internasional)
Tanggal Ujian : Senin, 23 April 2012-04-12
Tipe Ujian
: CLOSED BOOK
Waktu
: 100 menit
Dosen
: Yunita Sari, S. Kom., M. Sc.
1. A number sequence is described as follows 4, 28, 8, 2 , ...
Write an algorithm which is used to calculate the SUM from the first 10 whole
numbers (score: 20 points)
2. Determine the value of x, y and z after these following codes are executed (note: the
code in the points a, b, and c are NOT related each other) (score: 15 point)
a.
b.
c.
int x = 2, y = 2, z = 1;
switch(y)
{
case 1: x = 2; y = 3; break;
case 2: x = 4;
case 3: z = 5; break;
default: y = 3; x = 1;
}
double x = 10.0, y = 3.0;
int i = 3, z = 16;
if (x <= 10.0)
{
x = x / 2;
z = z/i ;
y = x + y + z;
i++;
y++;
}
cout << x << y << z <<i;
int x = 3, y = 2, z = 5;
for ( int i=3; i>0; i--)
x = x+i;
for ( int j=1; j<=3; j++)
y = y*j;
++z;
3. Write the nested loop code to display this following output! (score: 20 point)
1
2
3
4
2
4
6
8
3
6
9
12
4
8
12
16
5
10
15
20
5
10
15
20
25
6
12
18
24
30
7
14
21
28
35
8
16
24
32
40
4. Determine the output of this C++ program! (score: 20 point)
if (k % 3 + n <= l){
for (k=5; k>0; k--){
if (k == n%5)
cout <<k<<endl;
else if (k == n%2)
break;
else if (k == l/2)
cout<<"Circle 1A"<<endl;
cout<<"circle 1B"<<endl;
}
cout <<"circle 1C"<<endl;
}
cout <<"Circle 2A"<<endl;
5. There are two arrays called Array A and Array B as illustrated bellow. Both of them
are two dimension arrays. (score: 25 point)
20 34
1 2
12 18
65
3
19
Array A
20 34
1 2
12 18
64
3
19
Array B
Write a program that checks if every other element of array A is equal to it corresponding
element in array B. (ex : A[0][0] must equal to B[0,0], A[1,1] must equal to B[1,1] and so
on). The program will return true for equal and false for unequal.