Comprehensive notes for Chapter 10 Input and Output. Covers printf, scanf, Format Specifiers, Escape Sequences, and Character I/O.
Input: Process of giving something to the computer. Standard Input: Input via keyboard.
Output: Process of getting something from the computer. Standard Output: Output displayed on monitor.
Header File: stdio.h (Standard Input Output) contains definitions for standard I/O functions like printf and scanf.
Definition: Used to display output on monitor. Can display text, constants, or variable values.
Syntax: printf("Control String", Argument List);
Starts with % symbol. Determines data type, field width, and format.
%d (decimal), %i (integer), %o (octal), %x (hex lower), %X (hex upper), %u (unsigned).%f (float/double), %e (scientific lower), %E (scientific upper), %g (shortest of %f or %e).%c (char), %s (string).Field Width: Number of columns used to display value to text (e.g., %5d uses 5 columns).
Precision: Number of decimal places for floats (e.g., %.2f displays 2 decimal places).
Definition: Used to take input from the user. Stores input in specified variables.
Syntax: scanf("Format String", &variable1, &variable2, ...);
Special characters starting with backslash (\) used to modify output format. Not printed themselves.
\n: New Line. Moves cursor to start of next line.\t: Horizontal Tab. Moves cursor to next tab stop.\b: Backspace. Moves cursor one position back.\r: Carriage Return. Moves cursor to beginning of current line.\f: Form Feed (Page Break).\': Print Single Quote.\": Print Double Quote.\\: Print Backslash.Functions from conio.h to input single characters.
scanf limitation with spaces.conio.h.sizeof(int) returns 2).