본문 바로가기
정보처리산업기사

정보처리산업기사 실기 C언어 기출 10문제

by Hwangminseo 2026. 4. 7.

1번

문제
다음 C언어 프로그램의 실행 결과를 쓰시오.

#include <stdio.h>

int main() {
    int a = 5;
    int b = 2;
    printf("%d %d", a / b, a % b);
    return 0;
}

정답
2 1

핵심 개념

  • 정수 나눗셈
  • 나머지 연산자 %

2번

문제
다음 C언어 프로그램의 실행 결과를 쓰시오.

#include <stdio.h>

int main() {
    int a = 3;
    printf("%d\n", a++);
    printf("%d\n", ++a);
    printf("%d", a);
    return 0;
}

정답
3
5
5

핵심 개념

  • 후위 증가와 전위 증가
  • 순차 실행 결과

3번

문제
다음 C언어 프로그램의 실행 결과를 쓰시오.

#include <stdio.h>

int main() {
    char data[5] = {'B', 'A', 'D', 'E'};
    char c = 'C';
    int i, temp, temp2;

    printf("%d\n", data[3] - data[1]);

    for (i = 0; i < 5; i++) {
        if (data[i] > c)
            break;
    }

    temp = data[i];
    data[i] = c;
    i++;

    for (; i < 5; i++) {
        temp2 = data[i];
        data[i] = temp;
        temp = temp2;
    }

    for (i = 0; i < 5; i++) {
        printf("%c", data[i]);
    }

    return 0;
}

정답
4
BACDE

핵심 개념

  • 문자 아스키 코드
  • 배열 중간 삽입
  • 문자 이동

4번

문제
다음 C언어 프로그램의 실행 결과를 쓰시오.

#include <stdio.h>

int main() {
    int arr[3][3] = {
        {1, 2, 3},
        {4, 5, 6},
        {7, 8, 9}
    };
    int *parr[2] = {arr[1], arr[2]};

    printf("%d", parr[1][1] + *(parr[1] + 2) + **parr);
    return 0;
}

정답
21

핵심 개념

  • 포인터 배열
  • 2차원 배열
  • **parr, *(parr[1] + 2) 해석

5번

문제
다음 C언어 프로그램의 실행 결과를 쓰시오.

#include <stdio.h>
#include <string.h>

void copyStr(char *d, const char *s) {
    while (*s) {
        *d = *s;
        d++;
        s++;
    }
    *d = '\0';
}

int main() {
    const char *str1 = "first";
    char str2[20] = "teststring";

    copyStr(str2, str1);
    printf("%s", str2);

    return 0;
}

정답
first

핵심 개념

  • 문자열 복사
  • 널 문자 \0
  • 포인터를 이용한 문자열 처리

6번

문제
다음 C언어 프로그램의 실행 결과를 쓰시오.

#include <stdio.h>

void swap(int a, int b) {
    int t = a;
    a = b;
    b = t;
}

int main() {
    int a = 11;
    int b = 19;

    swap(a, b);

    switch (a) {
        case 1:
            b += 1;
        case 11:
            b += 2;
        default:
            b += 3;
            break;
    }

    printf("%d", a - b);
    return 0;
}

정답
-13

핵심 개념

  • 값에 의한 전달
  • switch fall-through
  • break 위치

7번

문제
다음 C언어 프로그램의 실행 결과를 쓰시오.

#include <stdio.h>

struct node {
    int n1;
    struct node *n2;
};

int main() {
    struct node a = {10, NULL};
    struct node b = {20, NULL};
    struct node c = {30, NULL};

    struct node *head = &a;
    a.n2 = &b;
    b.n2 = &c;

    printf("%d", head->n2->n1);
    return 0;
}

정답
20

핵심 개념

  • 구조체 포인터
  • -> 연산자
  • 연결 구조 추적

8번

문제
다음 C언어 프로그램의 실행 결과를 쓰시오.

#include <stdio.h>

typedef struct {
    int x;
    int y;
} Dat;

int main() {
    Dat a[] = {{1, 2}, {3, 4}, {5, 6}};
    Dat *ptr = a;
    Dat **pptr = &ptr;

    (*pptr)[1] = (*pptr)[2];

    printf("%d %d", a[1].x, a[1].y);
    return 0;
}

정답
5 6

핵심 개념

  • 이중 포인터
  • 구조체 배열
  • 구조체 전체 복사

9번

문제
다음 C언어 프로그램의 실행 결과를 쓰시오.

#include <stdio.h>

int main() {
    int data[] = {0xA0, 0xA5, 0xDB};
    int result = 0;

    for (int i = 0; i < 3; i++) {
        result += (data[i] & 0xA5);
    }

    printf("%d", result);
    return 0;
}

정답
454

핵심 개념

  • 비트 AND
  • 16진수
  • 비트 마스킹

10번

문제
다음 C언어 프로그램의 실행 결과를 쓰시오.

#include <stdio.h>
#include <stdlib.h>

typedef struct Data {
    int value;
    struct Data *next;
} Data;

Data* insert(Data* head, int value) {
    Data* new_node = (Data*)malloc(sizeof(Data));
    new_node->value = value;
    new_node->next = head;
    return new_node;
}

Data* reconnect(Data* head, int value) {
    if (head == NULL || head->value == value) return head;

    Data *prev = head;
    Data *curr = head->next;

    while (curr != NULL) {
        if (curr->value == value) {
            prev->next = curr->next;
            curr->next = head;
            head = curr;
            break;
        }
        prev = curr;
        curr = curr->next;
    }

    return head;
}

int main() {
    Data *head = NULL;

    for (int i = 1; i <= 5; i++) {
        head = insert(head, i);
    }

    head = reconnect(head, 3);

    for (Data *cur = head; cur != NULL; cur = cur->next) {
        printf("%d", cur->value);
    }

    return 0;
}

정답
35421

핵심 개념

  • 연결 리스트
  • 노드 재연결
  • 포인터 흐름 추적