CSS Computer Science (Optional) — Paper-I, Section-A, Topic II subtopic. How programs read input and produce output, and the categories of instructions that make up a program.
printf() — formatted output, uses format specifiers (%d int, %f float, %c char, %s string)scanf() — formatted input, requires the address-of operator & for non-string variables (e.g. scanf("%d", &age);)getchar() / putchar() — unformatted single-character input/outputgets() / puts() — unformatted string input/output (gets() is unsafe/deprecated — no bounds checking)cin >> — extraction operator, reads formatted input from stdincout << — insertion operator, writes formatted output to stdoutcerr — writes to stderr (unbuffered, for errors)getline(cin, str) — reads a full line including spaces (unlike cin >>, which stops at whitespace)printf/scanf, cin/cout)getchar/putchar, cin.get())| Statement Type | Purpose | Example |
|---|---|---|
| Declaration | Introduces an identifier and its type | <code>int x;</code> |
| Expression/Assignment | Evaluates an expression and optionally stores the result | <code>x = a + b;</code> |
| Control | Alters the normal sequential flow | <code>if(x>0){...}</code> |
| I/O | Transfers data in/out of the program | <code>cin >> x;</code> |
| Compound/Block | Groups multiple statements as one unit | <code>{ stmt1; stmt2; }</code> |
| Null | Does nothing (just a semicolon) | <code>;</code> |