UP | HOME

HW36
COP-3223H

Submit via webcourses.

Using only your mind and/or pencil and paper (do not compile and run the program) What is the output of the following program? If an output is an address rather than a known integer, just put ADDRESS (%p is the format specifier for printing a pointer).

#include <stdio.h>

int g(char board[3], int x) {
  board[2] = 'b';
  x = x + 1;
  return x;
}

int main(int argc, char **argv) {
  int x;
  char board[3];

  x = 2;
  for (int i = 0; i < 3; i++) {
    board[i] = 'a';
  }

  int y;
  y = g(board, x);
  printf("x is %d\n", x);
  printf("y is %d\n", y);
  printf("board is ");
  for (int i = 0; i < 3; i++) {
    printf("%c", board[i]);
  }
  printf("\n");
}

Author: Paul Gazzillo

Created: 2026-04-17 Fri 06:56

Validate