From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Challenge: Using printf placeholders

Challenge: Using printf placeholders - C Tutorial

From the course: Complete Guide to C Programming Foundations

Challenge: Using printf placeholders

(upbeat music) - [Instructor] In this challenge, you put your printf() placeholder muscle to use by declaring three variables to be used in a shopping program, a very simple shopping program. Declare a string, which is a character array, a quantity, and an item price. Use a printf() statement to inform the user of their purchase. For example, in my code, I set the string as fish umbrellas. The quantity is 12, and the price is 78.66. The program outputs this text. You have purchased 12 fish umbrellas at $78.66 each. The total cost is $943.92. Here are some things to remember. Ensure that you use the proper placeholders in each printf() statement. The prices must be formatted properly with two digits after the decimal. I've provided a code skeleton in the exercise files for you to use as a start. This challenge should take under 10 minutes to complete.

Contents