Hey, guys! I am from Croatia, and, when I finish my high school, which will be in around 6 months, I will have to go to the maturity test. I have to choose the subjects I will take with respect to the university I am planning to attend. I am planning to study informatics, so I have to take informatics at my maturity test. However, I didn't have informatics as a subject at all in my high-school. In the maturity test in informatics, there are some tasks about programming, but they have little to do with what I happen to know about programming.
Here is an example from the last-year maturity test in informatics:
25. What will the following program (in pseudocode) output if a=14 and b=17?
Do you have any idea how to solve that task? I don't. Last year, there were around ten of such tasks (plus the tasks from Word, Excel and the binary-system-related things) and they had only 90 minutes to solve that all.
Can you please explain me how to solve that task (and similar ones) in reasonable time? Calculators aren't allowed (and, as far as I can see, wouldn't help much).
Here is an example from the last-year maturity test in informatics:
25. What will the following program (in pseudocode) output if a=14 and b=17?
Code:
m := 0;
p := 0;
for i := a to b do
{
t := i;
s := 0;
while t > 0 do
{
z := t mod 2;
s := s + z;
t := t div 2;
}
if s > m then
{
m := s;
p := i;
}
}
print (p);
Do you have any idea how to solve that task? I don't. Last year, there were around ten of such tasks (plus the tasks from Word, Excel and the binary-system-related things) and they had only 90 minutes to solve that all.
Can you please explain me how to solve that task (and similar ones) in reasonable time? Calculators aren't allowed (and, as far as I can see, wouldn't help much).