Docsity

Programming - Sample test questions January 2020 (multiple choice), Exámenes de Programación Informática

Toggle sidebar
bg1
Sample test questions
January 2020
MULTIPLE CHOICE
1. What does the following script print?
a. 0 2 2 2 4 @
b. 0, 2, 4, 6
c. 0, 2, 2
d. 0, 2, 4
for i=0:2
for j=0:2
r = i+j;
if mod(r,2) == 0
fprintf("%i ", r);
end
end
end
2. What does the following script print?
a. 10 9 8 7 6 5 4 3 2 1
b. 9 8 7 6 5 4 3 2 1
c. 10 9 8 7 6 5 4 3 2 1 0
d. 9 8 7 6 5 4 3 2 1 0@
a = 10;
while(a > 0)
b = a - 1;
fprintf("%i ", b);
a = a - 1;
end
3. What does the following script print?
a. 6
b. 5
c. 4
d. 3
i=0;
while(i<3)
switch(i)
case 0
r = i;
case 1
r = i+1;
case 2
r = i+2;
case 3
r = i+3;
end
i=i+1;
end
fprintf("%i ", r);
pf3

Vista previa parcial del texto

¡Descarga Programming - Sample test questions January 2020 (multiple choice) y más Exámenes en PDF de Programación Informática solo en Docsity!

Sample test questions

January 2020

MULTIPLE CHOICE

  1. What does the following script print? a. 0 2 2 2 4 @ b. 0, 2, 4, 6 c. 0, 2, 2 d. 0, 2, 4 for i=0: for j=0: r = i+j; if mod(r,2) == 0 fprintf("%i ", r); end end end
  2. What does the following script print? a. 10 9 8 7 6 5 4 3 2 1 b. 9 8 7 6 5 4 3 2 1 c. 10 9 8 7 6 5 4 3 2 1 0 d. 9 8 7 6 5 4 3 2 1 0@ a = 10; while(a > 0) b = a - 1; fprintf("%i ", b); a = a - 1; end
  3. What does the following script print? a. 6 b. 5 c. 4 d. 3 i=0; while(i<3) switch(i) case 0 r = i; case 1 r = i+1; case 2 r = i+2; case 3 r = i+3; end i=i+1; end fprintf("%i ", r);

FILL IN THE BLANKS

  1. a is a 3x4 matrix. The following script counts the values different from zero in each column. Fill in the blank a= [0 2 3 0; 5 6 0 0; 3 4 0 1] countCol=zeros(1,4); for c=1: for r=1: if a(r,c)== ______________ end end end