C Programming - Short Notes
C Programming - Short Notes
1. Introduction to C:
C is a general-purpose programming language developed by Dennis Ritchie. It is widely used for system
programming and embedded systems.
2. Basic Structure of a C Program:
#include <stdio.h>
int main() {
// Code
return 0;
3. Data Types in C:
- int: Integer
- float: Decimal numbers
- char: Character
- double: Double precision float
4. Variables and Constants:
Variables store data; constants are fixed values.
Example: int a = 10;
5. Operators in C:
- Arithmetic: +, -, *, /, %
- Relational: ==, !=, >, <
- Logical: &&, ||, !
C Programming - Short Notes
6. Conditional Statements:
- if, if-else, nested if
- switch statement
7. Loops in C:
- for loop
- while loop
- do-while loop
8. Functions in C:
Functions help in reusability and modular code.
Example:
int add(int a, int b) {
return a + b;
9. Arrays and Strings:
- Arrays store multiple values of the same type.
- Strings are arrays of characters ending with ''.
10. Pointers in C:
Pointers store memory addresses. Example: int *ptr;
11. File Handling in C:
Used to read/write files using functions like fopen, fclose, fprintf, fscanf, etc.
12. Advantages of C:
- Fast execution
- Efficient memory management
- Powerful and flexible