- Executores
-
Aprender
Aprender Python Exemplos executáveis, NumPy, pandas e mais Aprender IA / Machine LearningRedes neurais, ML e LLMs do zero Aprender C e C++ Ponteiros, memória, STL e C++ moderno Aprender C#Fundamentos, POO, LINQ, async e exercícios .NET Aprender MatplotlibGráficos de linha, barras, dispersão e pizza com visualizadores Aprender RustOwnership, traits, tratamento de erros e threads Aprender GoSlices, interfaces, goroutines e channels Algoritmos em Python Busca, ordenação, recursão e visualizações O(n) Algoritmos em C e C++ Compare implementações em C e C++ Programação para crianças Aprenda a programar brincando!
- QuizzesNovo
- DesafiosNovo
- Para professoresNovo
- Atualizações
- Me pague um café
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.
Pergunta de exemplo
Pergunta 1 de 10The 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;
}
Mostrar a resposta
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 { }.
O que este quiz cobre
- Missing braces and off-by-one loop bounds
- Integer division in percentages
- Unsigned results from
strlen()subtraction and floating point equality getchar()into achar, uninitialised totals andsizeofon a heap pointer- The overflow in
(low + high) / 2
Perguntas frequentes
Preciso de uma conta?
Não. Qualquer pessoa pode jogar. Entre para guardar seu XP, sequência, badges e histórico.
Posso refazer?
Pode. Sua melhor nota fica salva, e as perguntas e respostas são embaralhadas a cada vez.