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 - 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
-
-
-
-
-
-
-
-
-
Using single character I/O3m 32s
-
(Locked)
Testing and converting characters3m 15s
-
(Locked)
Challenge: Character I/O and conversions34s
-
(Locked)
Solution: Character I/O and conversions1m 37s
-
(Locked)
Understanding strings in C2m 46s
-
(Locked)
Fetching string input3m 45s
-
(Locked)
Sending string output3m 41s
-
(Locked)
Challenge: Using printf placeholders1m 9s
-
(Locked)
Solution: Using printf placeholders1m 59s
-
(Locked)
Exploring string functions2m 41s
-
(Locked)
Manipulating strings2m 57s
-
(Locked)
Chapter challenge: Reading commands1m 52s
-
(Locked)
Chapter solution: Reading commands2m 31s
-
-
-
-
-