C Tokens, Keywords, Identifiers & Primitive Data Types
Unit 1: Algorithms, Flowcharts & C Program Architecture • Problem Solving Using C
👨🏫 Professor's Mental Model: The Alphabet, Grammar Rules & Sized Storage Containers
Jaise English bhasha me words, punctuation marks aur grammar hoti hai, waise hi C language ki sabse choti units ko Tokens kehte hain. Keywords dictionary ke wo 32 reserved shabd hain jinka matlab badla nahi ja sakta. Identifiers aapke banaye hue naam hain (jaise variable ya function ka naam). Aur Data Types alag-alag aakaar ke plastic dabbe hain: char 1-byte ka chota dabba hai, int 4-byte ka dabba hai, aur double 8-byte ka bada container hai!
Academic Lecture Notes & Solved Study Pages
Unit 1 • Core Concepts, Step-by-Step Proofs & Notebook Solutions
1. The 6 Categories of C Tokens
A Token is the smallest individual unit in a C program recognized by the compiler's lexical analyzer. The 6 token types are:
2. The 32 ANSI C Keywords & Identifier Naming Conventions
The 32 reserved keywords in standard ANSI C: auto, break, case, char, const, continue, default, do, double, else, enum, extern, float, for, goto, if, int, long, register, return, short, signed, sizeof, static, struct, switch, typedef, union, unsigned, void, volatile, while.
Mandatory Rules for Constructing Valid Identifiers:
3. Primitive Data Types, Memory Sizes & Ranges (32-bit/64-bit Architecture)
Fundamental data types allocate contiguous byte blocks in RAM:
| Data Type | Type Modifier | Size (Bytes) | Bits | Format Specifier | Typical Value Range |
|---|---|---|---|---|---|
| char | signed | 1 | 8 | %c / %d | -128 to 127 |
| char | unsigned | 1 | 8 | %c / %u | 0 to 255 |
| int | signed short | 2 | 16 | %hd | -32,768 to 32,767 |
| int | unsigned short | 2 | 16 | %hu | 0 to 65,535 |
| int | signed int | 4 | 32 | %d | -2,147,483,648 to 2,147,483,647 |
| int | unsigned int | 4 | 32 | %u | 0 to 4,294,967,295 |
| int | signed long long | 8 | 64 | %lld | -9.22 × 10^18 to +9.22 × 10^18 |
| float | standard | 4 | 32 | %f | ±1.2 × 10^-38 to ±3.4 × 10^38 (6 prec) |
| double | standard | 8 | 64 | %lf | ±2.3 × 10^-308 to ±1.7 × 10^308 (15 prec) |
| long double | extended | 12 or 16 | 96/128 | %Lf | ±3.4 × 10^-4932 to ±1.1 × 10^4932 (19 prec) |
Interactive Tested Code Example
#include <stdio.h>
#include <limits.h>
#include <float.h>
int main(void) {
printf("=== C DATA TYPE MEMORY ARCHITECTURE ===\n\n");
printf("char: %zu Byte | Min: %d to Max: %d\n", sizeof(char), CHAR_MIN, CHAR_MAX);
printf("short int: %zu Bytes | Min: %d to Max: %d\n", sizeof(short), SHRT_MIN, SHRT_MAX);
printf("int: %zu Bytes | Min: %d to Max: %d\n", sizeof(int), INT_MIN, INT_MAX);
printf("long long: %zu Bytes | Min: %lld to Max: %lld\n", sizeof(long long), LLONG_MIN, LLONG_MAX);
printf("float: %zu Bytes | Precision: %d digits\n", sizeof(float), FLT_DIG);
printf("double: %zu Bytes | Precision: %d digits\n", sizeof(double), DBL_DIG);
return 0;
}🎯 University Exam Scoring Blueprint
- In university exams, explicitly state that sizeof(char) is defined by the ANSI C standard as strictly 1 byte.
- Point out that int can be 2 bytes on 16-bit microcontrollers/Turbo C or 4 bytes on modern 32/64-bit GCC compilers.
- Identify valid and invalid identifier examples: _score (Valid), $amount (Invalid), 3rd_term (Invalid), student_age (Valid).