National Science and Mathematics Olympiad (NSMO) – Cities and Provinces Test: Informatics 1 (Juniors): free practice test
Start with 10 free questions to see what needs more practice. Finish to see your score, weakest units and every option explained.
Practice test questions with answers and explanations
Try the questions in the test above first, then open each one here to see the correct answer and why every other option is wrong.
01Which of the following is NOT a valid constant declaration?
Reference: Mawhiba NSMO 2026 Stage 1, Informatics 1 (Juniors) paper, question 2; official answer key (mawhiba.sa)
02What is the value of x after the following code is executed?
int x = 6;
x++;
x *= 3;
--x;
x /= 4;Reference: Mawhiba NSMO 2026 Stage 1, Informatics 1 (Juniors) paper, question 4; official answer key (mawhiba.sa)
03What will be printed after executing the following code?
if ((15 % 4 > 3) || (27 % 11 == 6)) {
cout << "first";
} else {
cout << "second";
}Reference: Mawhiba NSMO 2026 Stage 1, Informatics 1 (Juniors) paper, question 5; official answer key (mawhiba.sa)
04What is the value of n after the following code is executed?
int n = 0;
for (int i = 3; i < 10; i++) {
n += i;
}Reference: Mawhiba NSMO 2026 Stage 1, Informatics 1 (Juniors) paper, question 10; official answer key (mawhiba.sa)
05What is the value of k after the following code is executed?
int n = 20;
int k = 0;
while (n > 0) {
n -= k++;
}Reference: Mawhiba NSMO 2026 Stage 1, Informatics 1 (Juniors) paper, question 11; official answer key (mawhiba.sa)
06What is the value of n after the following code is executed?
int n = 478;
while (n > 100){
n -= n % 11;
n -= 4;
}Reference: Mawhiba NSMO 2026 Stage 1, Informatics 1 (Juniors) paper, question 17; official answer key (mawhiba.sa)
07How many different outputs can the function f return over all possible values of i?
int f(int i) {
int j = (i > 0 ? i : -i);
return (j % 2) * (j % 3) * (j % 4);
}Reference: Mawhiba NSMO 2026 Stage 1, Informatics 1 (Juniors) paper, question 16; official answer key (mawhiba.sa)
08What is the result of calling rec(261074)?
int rec(int x){
if (x == 0) return 0;
if (x % 10 == 0) return rec(x / 10);
return 1 + rec(x - 1);
}Reference: Mawhiba NSMO 2026 Stage 1, Informatics 1 (Juniors) paper, question 18; official answer key (mawhiba.sa)
09What is the value of count after the following code is executed?
int m[5][5] = {
{1, 1, 0, 1, 0},
{1, 1, 1, 1, 1},
{0, 1, 1, 1, 0},
{1, 1, 1, 1, 1},
{1, 1, 0, 1, 1}
};
int count = 0;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if (m[i][j] && m[i][j + 1] && m[i + 1][j] && m[i + 1][j + 1]) {
count++;
}
}
}Reference: Mawhiba NSMO 2026 Stage 1, Informatics 1 (Juniors) paper, question 14; official answer key (mawhiba.sa)
10What is the value of steps after the following code is executed?
char b[][7] = {
{'#', '#', '#', '#', '#', '#', '#'},
{'#', '.', '.', '#', '.', '.', '#'},
{'#', '#', '.', '.', '.', '#', '#'},
{'#', '.', '#', '.', '.', '.', '#'},
{'#', '.', '.', '.', '#', '#', '#'},
{'#', 'o', '.', '.', '.', '.', '#'},
{'#', '#', '#', '#', '#', '#', '#'}
};
int pi = 3;
int pj = 3;
int di = -1;
int dj = 0;
int steps = 0;
while (b[pi][pj] != 'o') {
if (b[pi + di][pj + dj] != '#') {
pi += di;
pj += dj;
steps++;
} else {
int di_ = di;
di = -dj;
dj = di_;
}
}Reference: Mawhiba NSMO 2026 Stage 1, Informatics 1 (Juniors) paper, question 19; official answer key (mawhiba.sa)
Full prep for this exam
All of this in one purchase.
- Full mock exam, same as the real one20 questions in 120 minutes. You get a total score and a score for every unit.
- Practice unit by unit510 questions, every option explained with its source. Starts with your weakest units.
- Complete Review Guide 2026–2027 (PDF)Ordered by each unit's weight in the exam. With lifetime access only.
Choose your access
Continue with your Google account and you go straight to the payment page.
