C Programming Notes
Day 1: Introduction to C
C is a powerful general-purpose programming language. It is used for system programming, game
development,
and software applications.
Basic Structure of a C Program:
1. Preprocessor Directives (#include <stdio.h>)
2. Main Function (int main())
3. Statements inside { }
4. Return Statement (return 0;)
Example:
#include <stdio.h>
int main() {
printf("Hello, World!");
return 0;
}
Day 2: Variables and Data Types
Variables store data in memory. Each variable has a data type.
Common Data Types:
- int (Integer) -> Example: int a = 5;
- float (Decimal) -> Example: float pi = 3.14;
- char (Character) -> Example: char letter = 'A';
- double (Large Decimal) -> Example: double num = 10.234;
Example:
#include <stdio.h>
int main() {
int num = 10;
float pi = 3.14;
printf("%d %f", num, pi);
return 0;
}
Day 3: Operators in C
Operators are symbols that perform operations on variables.
1. Arithmetic Operators: +, -, *, /, %
2. Relational Operators: ==, !=, >, <, >=, <=
3. Logical Operators: &&, ||, !
4. Bitwise Operators: &, |, ^, ~, <<, >>
5. Assignment Operators: =, +=, -=, *=, /=, %=
6. Increment & Decrement: ++, --
Example:
#include <stdio.h>
int main() {
int a = 5, b = 3;
printf("%d", a + b); // Output: 8
return 0;
}