C_Programming_Notes
C_Programming_Notes
1. Introduction to C:
- Developed by Dennis Ritchie in 1972.
- General-purpose, procedural programming language.
- Used for system programming, OS development, embedded systems.
2. Structure of a C Program:
#include <stdio.h>
int main() {
// code
return 0;
}
- Every C program starts with main().
- #include is used to include standard libraries.
5. Operators:
- Arithmetic: +, -, *, /, %
- Relational: ==, !=, >, <, >=, <=
- Logical: &&, ||, !
- Assignment: =, +=, -=, *=, /=
6. Control Statements:
- Decision making: if, if-else, switch
- Loops: for, while, do-while
- Jump statements: break, continue, goto
7. Functions:
- Functions help in modular programming.
- Syntax: return_type function_name(parameters) { //code }
- Functions can be called from main or other functions.
- Example:
int add(int a, int b) {
return a + b;
}
9. Pointers:
- A pointer stores the address of a variable.
- Declared with * operator. Example: int *ptr;
- & gives address of variable, * dereferences pointer.
Tips:
- Practice by writing programs daily.
- Focus on logic building and understanding memory management.
- Debug and test your code thoroughly.