Question 14 of 110Programming Basicsc output

Consider the following C program carefully. What will be printed on the screen when this program is compiled and executed?

#include <stdio.h>
int main() {
    int a[5] = {12, 3, 18, 5, 9};
    int i, mx = a[0], mn = a[0];
    for (i = 1; i < 5; i++) {
        if (a[i] > mx) mx = a[i];
        if (a[i] < mn) mn = a[i];
    }
    printf("%d", mx - mn);
    return 0;
}

The verified answer and full solution are one login away

Every answer here is machine verified, with a step-by-step solution that teaches the method. Your login also unlocks a 7-question mock preview in the real exam interface.

Log in to see the answer
← Q13Q15Attempt the full timed mock

More c output questions