You are on page 1of 3

Company

When we need find a solution in a interview, to use the pseudocode its much better.

Concept of Variable: space on the memory to save a value

Begin

read num[0], num[1], ..., num[n];


max = num[0];

for (i=1 to n)

if (num[i] > max)


then max = num[i];
end if

write (max);

End;

Begin

read num[0], num[1], ..., num[n];


min = num[0];

for (i=1 to n)
if (num[i] < min)
then min = num[i];
end if
end for

write (min);

End;

Minimum between 2 values

Begin
read a, b;
min = a;
if (b < min)
then min = b;
end if
write (min);
End;
tlazri@gmail.com

Minimum between 3 values

Begin
read a, b, c;
min = a;
if (b < min)
then min = b;
end if
if (c < min)
then min = c;
end if
write (min);
End;

Maximum between 3 values

Begin
read a, b, c;
max = a;
if (b > max)
then max = b;
end if
if (c > max)
then max = c;
end if
write (max);
End;

Admission system or grading system

firstname
lastname

marks1
marks2

average = (marks1 + marks2) / 2;

grade A if average >= 90


B if average >= 80 and < 90
C if average >= 60 and < 80
F if average < 60

firstname lastanme grade

Begin

read firstname;
read lastname;
read marks1;
read marks2;

average = (marks1 + marks2) / 2;

grade = "F";
if (average >= 60)
grade = "C";
end if;
if (average >= 80)
grade = "B";
end if;
if (average >= 90)
grade = "A";
end if;

write ( firstname + " " + lastname + " " + grade);


End;

Begin

i =1;
sum = 0;

while (i<= 4)
{
sum = sum + i;
i = i +1;
}
print sum;

End;

Begin

i = 1;
total = 0;
while (i<= 6)
{
total = total + i;
i = i + 1;
total = total - i;
i = i + 1;
}

print total;

End;

You might also like