C Language - Short Notes (With Full Experience)
1. Introduction to C
C is a general-purpose, procedural programming language developed by Dennis Ritchie in 1972. It is known
for its speed, efficiency, and close-to-hardware capabilities. It is widely used in system programming,
embedded systems, and operating system development.
2. Features of C
- Fast and Efficient
- Low-level Access to Memory (Pointers)
- Procedural Language
- Portable Code
- Rich Library
- Compiler-Based
3. Structure of a C Program
1. Preprocessor Commands: #include <stdio.h>
2. main() Function: Starting point of the program
3. Variable Declaration
4. Logic / Statements
5. Return Statement
Example:
C Language - Short Notes (With Full Experience)
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
4. Data Types in C
- int: Integer (e.g., 5)
- float: Decimal (e.g., 3.14)
- char: Single character (e.g., 'A')
- double: Large decimal
- void: No return type
5. Variables and Constants
Variables: Containers to store data values.
Example: int age = 21;
Constants: Fixed values that do not change during execution.
Example: const float PI = 3.14;
6. Operators in C
C Language - Short Notes (With Full Experience)
- Arithmetic (+, -, *, /, %)
- Relational (==, !=, >, <, >=, <=)
- Logical (&&, ||, !)
- Assignment (=, +=, -=)
7. Control Statements
- if, if-else, nested if
- switch-case
- loops: for, while, do-while
8. Functions
Functions break the code into reusable blocks.
Syntax:
return_type function_name(parameters) {
// code
Example:
int add(int a, int b) {
return a + b;
}
C Language - Short Notes (With Full Experience)
9. Arrays and Strings
Arrays: Collection of similar data items.
Example: int nums[5] = {1, 2, 3, 4, 5};
Strings: Array of characters ending with null character ''.
Example: char name[] = "Yash";
10. Pointers
Pointers store the address of a variable.
Example:
int x = 10;
int *p = &x;
printf("%d", *p); // Output: 10
11. File Handling
Used to store data permanently.
Functions:
- fopen()
C Language - Short Notes (With Full Experience)
- fclose()
- fprintf(), fscanf()
- fread(), fwrite()
12. Use Cases of C
- Operating System Development
- Embedded Systems
- Game Development
- Compiler Design
- Microcontroller Programming