Programming Fundamentals
1. Four Ps in Programming:
- Problem: Identify the problem to solve.
- Plan: Design a solution or algorithm.
- Program: Write the code using a programming language.
- Process: Run the program and verify the result.
2. Generations of Programming Languages:
- 1st Generation: Machine language (binary code).
- 2nd Generation: Assembly language (low-level).
- 3rd Generation: High-level languages (C, Java, Python).
- 4th Generation: SQL, report generators.
- 5th Generation: Logic-based, AI programming (Prolog).
3. Types of Programming Languages:
- Procedural: Uses procedures/functions (e.g., C).
- OOP: Object-Oriented Programming (e.g., Java, C++).
- Imperative: Commands that change state (C, Python).
- Functional: Uses functions, no state changes (Haskell).
- Logic-based: Uses facts and rules (Prolog).
4. C Language:
- History: Developed in 1972 by Dennis Ritchie.
- Advantages: Fast, portable, structured, widely used in system programming.
5. How to Do Programming in C (IDE):
- Use IDEs like Turbo C, Code::Blocks, Dev C++, Visual Studio Code.
- Write, compile, and run C programs.
6. Structure of C Language / Programming:
#include <stdio.h>
int main() {
// code
return 0;
7. Variables and Identifiers:
- Variable: Stores data.
- Identifier: Name of a variable/function.
- Types: int, float, char
8. Declaration and Initialization:
- Declaration: int a;
- Initialization: int a = 5;
9. Data Types:
- Primary: int, char, float, double
- Derived: array, pointer, structure
- User-defined: structure, union, enum
10. Looping in C:
- For loop, While loop, Do-while loop
- Counter/fixed loops
11. Conditional Statements:
- Simple: if (condition)
- Compound: if-else
- Complex: if-else if-else, switch
12. Arrays:
- One-dimensional: int arr[5];
- Two-dimensional: int arr[3][3];
- Multi-dimensional: 3D or more
13. Structure:
struct Person {
int age;
char name[20];
};
14. Union:
union Data {
int i;
float f;
};
15. Graphics in C:
- Use libraries like graphics.h to draw shapes.
16. Operators:
- Arithmetic: +, -, *, /
- Relational: >, <, ==
- Logical: &&, ||, !
- Assignment: =, +=, -=
- Bitwise: &, |, ^