programmering h1 Flashcards

1
Q

Vilket värde har variabeln x vid programmets slut?
x = 0;
for k = 1:100
x = x + k

A

5050

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Vilket tal y beräknar programmet en approximation till?
y = 1;
for k = 1:1000
y = (y^2+2)/(2*y)

A

√2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Vilket värde har variabeln x vid programmets slut?
x = 0;
a = 1;
for k = 1:2:7
x = x - a;
a = a / 2;

A
  • 15/8
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Vilket tal y beräknar programmet då h →0?
h = 1;
x = 1/27;

for k = 1:10
h = h / 2;
y = (log (x + h) - log (x - h)) / (2*h);
y = y / 2;

A

27/2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Vilket tal x beräknar programmet?
x = 0;
for k = 1:100
x = x + 2*k/100;

A

101

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Vilket tal x beräknar programmet?
x = 3;
k = 0;

while k < 10
x = foo(x);
k = k + 1;

function y = foo(x)
y = 2*x;

A

3072

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Vilket tal beräknar programmet?
x = 0;
for k = 0:10
x = x + 0.5^(2k + 1) / factorial (2k + 1)
* (-1)^k

A

sin(1/2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly