C: Find the Bug

This C quiz is a code review in ten questions. Each program contains a bug that compiles (or almost does), from missing braces to char holding EOF, and you have to say what really happens and how to fix it.

어려움 10문제 약 8분 합격 기준 80% C17

모드 선택

게스트로 플레이 중이에요. 로그인하면 XP와 연속 기록이 저장돼요.

예시 문제

10문제 중 1번

The withdrawal is smaller than the balance, so the author expects 50. What does this print?

#include <stdio.h>

int main(void) {
    int balance = 100, amount = 50;
    if (amount > balance)
        printf("declined ");
        amount = 0;
    balance -= amount;
    printf("%d\n", balance);
    return 0;
}
정답 보기

C. 100 Without braces only the first statement belongs to the if. amount = 0; always runs despite its indentation, so nothing is withdrawn; wrap both lines in { }.

이 퀴즈에서 다루는 내용

  • Missing braces and off-by-one loop bounds
  • Integer division in percentages
  • Unsigned results from strlen() subtraction and floating point equality
  • getchar() into a char, uninitialised totals and sizeof on a heap pointer
  • The overflow in (low + high) / 2

자주 묻는 질문

계정이 필요한가요?

아니요. 누구나 플레이할 수 있어요. 로그인하면 XP, 연속 기록, 배지, 기록이 저장돼요.

다시 풀 수 있나요?

네. 최고 점수가 저장되고, 문제와 보기는 매번 섞여서 나와요.