Programming languages are categorized based on their proximity to computer hardware.
Every C program follows a standard template to ensure the compiler can process the code correctly.
/* Documentation Section: Description of program */
#include <stdio.h> // Link Section: Preprocessor directives
// Global Declaration Section (Optional)
int main() // Main Function Section
{
// Declaration part
// Execution part
return 0;
}
The Character Set includes all characters that the C compiler recognizes.
Keywords are reserved words that have a predefined meaning to the C compiler. They cannot be used as names for variables.
Rule: There are 32 standard keywords in C (e.g., int, float, if, else, while, return).
Identifiers are user-defined names given to various program elements like variables, functions, and arrays.
A variable is a data name used to store a data value that can change during program execution.
Example: int age = 20; (Here, 'age' is a variable).
A constant is a value that does not change during the program execution.
| Constant Type | Examples |
|---|---|
| Integer Constants | 10, -50, 1000 |
| Real (Floating-point) | 3.14, -0.005, 1.5 |
| Character Constants | 'A', 'z', '5' |
| String Constants | "Hello", "Knowlet", "123" |
Q: What is the difference between an identifier and a keyword?
A: A keyword is a reserved word with a fixed meaning; an identifier is a name created by the programmer for variables or functions.
Q: Why is C called a Middle-Level language?
A: Because it combines the features of low-level languages (direct memory access) with the ease of high-level languages.