1.
Concepts of Algorithm, Flowchart and Pseudocode
- Algorithm: A step-by-step procedure to solve a problem.
- Flowchart: A diagrammatic representation of the steps.
- Pseudocode: A way to describe algorithms using structured language.
Steps to write an algorithm:
1. Understand the problem
2. Input and output requirements
3. Write step-by-step logic
Flowchart Symbols:
- Start/End: Oval
- Process: Rectangle
- Decision: Diamond
- Input/Output: Parallelogram
Pseudocode constructs:
- Sequencing: Steps in order
- Looping: For, While
- Condition: If, Else
Examples:
- Even/Odd, Prime, HCF/LCM
- Series (Fibonacci), Bubble Sort, Insertion Sort
- Searching: Linear, Binary
2. Concept of Program, Programming, and C Language
- Program: Set of instructions to perform a task.
- Programming: Writing code to solve problems.
- C Language: General-purpose, procedural language.
Basic terms:
- Constants: Fixed values
- Variables: Named storage
- Identifiers: Names given to entities
- Keywords: Reserved words
Backslash characters: \n, \t, \b, etc.
Structure of C Program:
- Headers, main(), functions, statements
Operators:
- Arithmetic (+, -, *, /)
- Relational (==, !=, >)
- Logical (&&, ||, !)
- Increment/Decrement (++, --)
3. Data Types, Operators and I/O Functions
- Data Types: int, float, double, char
- Modifiers: short, long, signed, unsigned
- Format specifiers: %d, %f, %c, %s, etc.
Operators:
- Assignment (=)
- Conditional (?:)
- Bitwise (&, |, ^, <<, >>)
- sizeof: memory occupied
I/O Functions:
- printf(), scanf()
- gets(), puts()
- getchar(), getch()
4. Conditional, Looping and Jump Statements
Conditional:
- if, if-else, nested if-else, else-if ladder
- switch-case for multiple branching
Looping:
- while, do-while, for
- Nested loops
Jumping:
- break: exit loop
- continue: skip iteration
- goto: jump to label
- return: exit from function
- exit(): terminate program
5. Arrays
- Array: Collection of similar data types
- Declaration: int a[5];
- Initialization: int a[5] = {1,2,3,4,5};
- Access: a[0], a[1], ...
Single Dimensional:
- Traverse using loop
Two Dimensional:
- int matrix[3][3];
- Used in tables, matrices
6. Strings and Functions
Strings:
- Array of characters ending with '\0'
- gets(), puts(), strlen(), strcmp(), strcpy(), strcat()
Functions:
- Reusable blocks of code
- Types: Library, User-defined
- Prototype, Definition, Calling
- Return statements, Recursion
- main(): Entry point
- Local/Global variables
7. Pointers, Structures, and File I/O
Pointers:
- Store address of variables
- int *p = &x;
- *p to access value
Structures:
- User-defined data type
- struct Student { int id; char name[20]; };
File I/O:
- FILE *fp; fopen(), fclose()
- fgetc(), fputc(), fgets(), fputs()
- fprintf(), fscanf()