Placeholders

Placeholders are used both to print something to the screen and to take input from the user. They quite literally “hold the place” of the variable in printf() and scanf() statements. Below are the placeholders for the data types we have introduced thus far:

Let’s see these placeholders used in action!

Here is an example of a placeholder used in a printf() statement:

int number = 8;
printf(“The value of number is %d”, number);

There are several new components worth talking about that make up the above code. The first line is where we created a variable called “number” of type int and assigned it the value 8. In the second line, we have our printf() statement, in which we have quotation marks with text we want to display to the user. In addition to just the text, though, we also have a placeholder inside the quotation marks.