What you will learn
Store whole numbers, decimal values and characters.
Understand the concept
A variable has a type and a value. int stores integers, double stores floating-point values and char stores a character. printf uses format specifiers that must match the supplied argument types: %d for int, %f for double and %c for a character.
Read the example
The complete program appears below. Read it first, predict the output, then run it.
Expected output
Quantity: 3, price: 125.50, grade: A
Practise
Add a variable for total cost and print quantity multiplied by price.
Common mistake
Do not read an uninitialized variable. Single quotes represent a character; double quotes represent a string.
