





























Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!






























P R O G R A M M I N G
Y E A R 2 0 2 0 - 2 0 2 1
CONTENTS
i<=
True False
printf("%i\n", i);
i=
i= i+
i<=
True False
printf("%i\n", i);
i=
i= i+
initial_value: step :endl_value
list of values (array)
for iterator = values
[statement]
end
Control expression
True
False
statements
initialization
update
% version 1: step explicit
for i= 2:1:
fprintf("%i\n", i);
end
% version 2: step omitted
for i= 2:20 % step? - > default value 1
fprintf("%i\n", i);
end
iterator >= end_value
11
17
% example infinite loop
a=45;
while (a<100)
fprintf('aaaaaaaa\n');
a = a -1;
end
n = 32;
while n>
fprintf('%i ',n);
n = n / 2;
end
password = 1234; % set password
attempts=0; %initialize attempts to 0
number = 0; % initialize number
while ((number ~= password )&&( attempts < 3))
number = input('Enter pin: ');
attempts=attempts+1;
if (number~= password)
disp('incorrect, re-enter');
end
end
if (number == password)
disp('Welcome');
else
disp('Account locked!!');
end
Post-check
The while block ends when the password is
found or when the maximum number of
attempts limit is reached.
You need to check which one is true