Fix a compiler error
Read an error message and repair the code. An easy embedded C problem (First steps in C), run and graded in the browser.
easy · First steps in C · syntax · debugging
This function is meant to return twice its input, but it does not compile. Press Run, read the error message and the line number it points to, then fix the code.
Reading compiler errors is a skill you will use every day.
Starter code
int double_it(int x) {
return x * 2
}Example tests
Doubles a positive number
printf("%d\n", double_it(4));Expected output:
8Doubles a negative number
printf("%d\n", double_it(-3));Expected output:
-6Learn it first
- Microcontrollers and your first program · What a microcontroller is, how code gets onto it, and the parts of a C program.
More First steps in C problems
- Return a value · Make a function hand back a number.
- Add two numbers · Use the inputs a function receives.
- Minutes to seconds · Convert a duration with one multiplication.
- Area of a rectangle · Combine two parameters into one result.
- Print a line · Send text to the output with printf.
- Print a number · Put a value into printed text with a placeholder.