← Back to archive

Stdle #148 · pointers · 2026-11-01

What does this C snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

#include <stdio.h>
void minmax(const int *a, int n,
int *mn, int *mx) {
*mn = a[0];
*mx = a[0];
for (int i = 1; i < n; i++) {
if (a[i] < *mn) *mn = a[i];
if (a[i] > *mx) *mx = a[i];
}
}
int main(void) {
int a[5] = {4, 1, 7, 3, 9};
int lo, hi;
minmax(a, 5, &lo, &hi);
printf("%d %d\n", lo, hi);
return 0;
}
Pointers
4 attempts left

Answer & explanation