Print a number
Put a value into printed text with a placeholder. An easy embedded C problem (First steps in C), run and graded in the browser.
easy · First steps in C · printf · format
Inside the quotes of a printf, %d is a placeholder. It is replaced by the whole number given after the text.
Make show_reading print reading = followed by the value and a newline. For 25 the output is reading = 25.
Starter code
void show_reading(int value) {
printf("reading = \n");
}Example tests
A positive reading
show_reading(25);Expected output:
reading = 25A negative reading
show_reading(-3);Expected output:
reading = -3Learn 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.
- Fix a compiler error · Read an error message and repair the code.
- 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.