C PROGRAMMING
MULTIPLE CHOICE QUESTION
OLD QUESTION BANK
SAMPLE QUESTION 2080 AND SOLUTION

Introduction to Data Input/Output In C Programming


In C programming, input and output (I/O) operations involve the communication of data between the program and external sources or destinations. Here are the basic concepts:

  • Input Operation:
    • Concept: Input operations involve receiving data into the program from external sources.
    • Example: Reading data from the keyboard, reading from a file, or obtaining input data from a sensor.
    • Function: The scanf() function defined in the stdio.h header file is commonly used for standard input (e.g., keyboard input).
  • Output Operation:
    • Concept: Output operations involve sending data from the program to external destinations.
    • Example: Displaying information on the screen, writing to a file, or sending data to a printer.
    • Function: The printf() function defined in the stdio.h header file is commonly used for standard output (e.g., displaying on the console).

 

The value for the input and output operations can be of any data type: integer, float, character or string depending upon the programming problem. The standard input functions like scanf(), getchar() etc are used to read user input from standard input devices while the standard output functions like printf(), putchar() are used to write the program result and data to standard output devices. Most of the standard I/O functions are defined within the stdio.h header files, hence the file is first included in the source code before writing the main() functions. 

 

The functions for standard I/O operations are classified into two categories: 

  1. Formatted I/O
  2. UnFormatted I/O 

Formatted Input/Output:

Formatted I/O refers to the process of reading or writing data in a specific format, with controlled spacing, alignment, and representation. Formatted I/O functions typically use format specifiers  in the function argument to define the layout of the data. Example : printf() and scanf() functions

Unformatted Input/Output:

Unformatted I/O involves reading or writing data without specific formatting instructions. Data is typically processed as a sequence of bytes. Unformatted I/O functions deal with raw data without specific formatting details. Example: getchar(), putchar(), fread(), fwrite() etc.

The diagram below summarizes different formatted Input/Output function available in C Programming: