Published online by Cambridge University Press: 17 July 2025
In the previous chapters we have learnt how variables can be declared and initialized, what are the different operators available in C and using these operators how a meaningful expression can be written. Now, we will discuss how the input and output operations are carried out in C.
C language does not have any input or output statement. All the input and output operations are accomplished using some library functions. These are included in stdio.h and conio.h header files. These input and output functions or in short, I/O functions are categorized into three groups. These are:
1. Console I/O functions which deal with keyboard and monitor,
2. Disk I/O functions which deal with hard disk or floppy disk and
3. Port I/O functions which deal with different port.
In this chapter, we will discuss only about some console I/O functions that are used frequently. These console I/O functions can be categorized into formatted I/O functions and unformatted I/O functions.
FORMATTED I/O FUNCTIONS
Formatted input refers to read or input data using keyboard in a particular format and formatted output refers to print or display (i.e., output) data or message in the VDU in a formatted way means when a set of values will be displayed, the sequence of the fields, their widths, spaces among the values, etc. can be specified. The standard library function scanf( ) is used for formatted input operation and printf( ) is used for formatted output operation.
To save this book to your Kindle, first ensure no-reply@cambridge-org.demo.remotlog.com is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.
Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.
Find out more about the Kindle Personal Document Service.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.
To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.