% while -> exercises
clear;
clc;
disp('Exercise 1');
N = 3;
n = 1;
while n <= N
   disp('*');
   n = n + 1;
end

disp('Exercise 2');
if N > 80
   P = 80;
else
   P = N;
end
n = 1;
starline = '';
while n <= P
   starline = [starline '*'];
   n = n + 1;
end
disp(starline);

disp('Exercise 3');
val = -1;
while val < 0
    val = input('Enter a positive integer or 0 to exit loop: ');
end

disp('Exercise 4');
N = 3;
values = [randperm(5) randperm(3) randperm(6)];
k = 1;                % index of first value to check
K = length(values);   % index of last value to check
count = 0;            % initialize a counter variable
while k < K
   if values(k) == N
       count = count + 1;
   end
   k = k + 1;
end
disp(['There are ', num2str(count), ' values of ', num2str(N),' in the vector: ', num2str(values)]);