8. Can I Ask the User Questions?

With scanf()

image

printf() sends data to the screen. The scanf() function gets data from the keyboard. You must have a way to get data from your user. You can’t always assign data values using assignment statements. For example, if you were writing a video rental program for use throughout the country, you couldn’t assign the cost of a tape rental to a variable using the equals sign in your program because every store’s rental could differ. Instead, you would have to ask the user of the program in each store location how much ...

Get Absolute Beginner’s Guide to C, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.