- Ejecutores
-
Aprender
Aprender Python Ejemplos ejecutables, NumPy, pandas y más Aprender IA / Machine LearningRedes neuronales, ML y LLM desde cero Aprender C y C++ Punteros, memoria, STL y C++ moderno Aprender C#Fundamentos, POO, LINQ, async y ejercicios de .NET Aprender MatplotlibGráficos de líneas, barras, dispersión y sectores con visualizadores Aprender RustOwnership, traits, manejo de errores e hilos Aprender GoSlices, interfaces, goroutines y canales Algoritmos en Python Búsqueda, ordenación, recursión y visualizadores O(n) Algoritmos en C y C++ Compara implementaciones en C y C++ Programación para niños ¡Aprende a programar jugando!
- QuizzesNuevo
- RetosNuevo
- Para docentesNuevo
- Actualizaciones
- Invítame a un 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.
Pregunta de ejemplo
Pregunta 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;
}
Ver la respuesta
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 { }.
Qué cubre este quiz
- 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
Preguntas frecuentes
¿Necesito una cuenta?
No. Cualquiera puede jugar. Inicia sesión para guardar tu XP, racha, insignias e historial.
¿Puedo repetirlo?
Sí. Se guarda tu mejor puntuación, y las preguntas y respuestas se mezclan cada vez.