UNIT 1 Identifiers: Names for variables, functions.
for(i=n-1;i>=pos;i--) arr[i+1] = arr[i];
10 Marks Questions UNIT 2 arr[pos] = value;
1) Block Diagram of Computer 10 Marks Questions // Delete
Input Unit → Process Unit (CU+ALU+Memory) → Output Unit. 1) Decision Making Statements for(i=pos;i<n-1;i++) arr[i] = arr[i+1];
Input Unit: Takes data from user (e.g., Keyboard, Mouse). if, if-else, nested if, if-else ladder, switch. UNIT 4
Processing Unit: 2) Looping Control Statements 10 Marks Questions
Control Unit (CU): Directs all operations. for loop:Used when number of iterations is known. 1) Parameter Passing (Call by Value/Reference)
ALU (Arithmetic Logic Unit): Performs calculations. while loop: Entry controlled loop. Call by Value: Copy of actual argument passed.
Memory Unit: Stores data. do-while loop: Exit controlled loop (runs at least once). Call by Reference: Address passed; changes affect original
Output Unit: Shows results (Monitor, Printer). 3) Jumping Statements 2) Storage Classes
2) Operators in C break: Exits loop/switch. auto, extern, static, register
Arithmetic Operators: +, -, *, /, %. continue: Skips current iteration Defines scope, visibility, and lifetime of variables
Relational Operators: ==, !=, >, <, >=, <=. goto: Jumps to a labeled part of code. 3) Pointers Declaration, Initialization, Accessing
Logical Operators: &&, ||, !. 5 Marks Questions int *p;
Assignment Operators: =, +=, -=, etc. 1) Switch Statement Example int x = 10;
Bitwise Operators: &, |, ^, ~, <<, >>. switch (choice) { p = &x;
Miscellaneous: sizeof(), ?: (ternary), , (comma operator). case 1: printf("One"); break; printf("%d", *p);
3) Flowchart and Algorithm with Example case 2: printf("Two"); break; 4) Function and Categories
Algorithm: Step-by-step instructions to solve a problem. default: printf("Invalid choice"); Function: Block of code that performs task.
Example: } Categories:
1. Start 2) Difference between break and continue | Break | Continue | |:----- No arguments, no return
|:---------| | Terminates the loop | Skips to next iteration | | Used with
2. Read two numbers loops and switch | Used with loops only | With arguments, no return
3. Add numbers 3) Difference between while and do-while | while | do-while | |:------ No arguments, with return
|:---------| | Entry controlled | Exit controlled | | May not run if
4. Display sum With arguments, with return
condition false | Runs at least once |
5. End 5 Marks Questions
4) Goto & Return Statement
Flowchart: Diagram representing the algorithm (uses shapes like 1) Recursion Example
goto: Transfers control to another label.
oval, parallelogram, rectangle).
int fact(int n) {
return: Ends function and returns value.
4) Programming Languages
if(n==0) return 1;
UNIT 3
Machine Language: 0s and 1s, machine-dependent.
else return n * fact(n-1);
10 Marks Questions
Assembly Language: Uses mnemonics like ADD, SUB.
}
1) Arrays and Types
High-Level Language: Closer to English, like C, Python
2) Pointer: Advantages and Disadvantages
Array: Collection of similar elements.
4) Datatypes and Constants
Advantages: Efficiency, dynamic memory, data structures.
Types:
Datatypes:
Disadvantages: Complex, error-prone, security issues.
1D Array
int, float, char, double, etc
3) Pointer Arithmetic and Pointers with Arrays
2D Array (Matrix)
Constants: Fixed values that do not change.
p = arr;
Multidimensional Array
Types: Integer constant, Character constant, Floating constant,
String constant. *(p+2) => arr[2];
2) String Handling Functions
5 Marks Questions UNIT 5
Functions: strlen(), strcpy(), strcmp(), strcat().
1) Software and its Types 10 Marks Questions
Example:
Software: Set of programs to perform tasks. 1) Dynamic Memory Allocation
char s1[20], s2[20];
Types: Functions: malloc(), calloc(), realloc(), free().
strcpy(s1, "Hello");
System Software: OS, Compiler. Example:
strcat(s1, "World");
Application Software: MS Word, Games. int *p = (int*)malloc(5 * sizeof(int));
printf("%s", s1);
2) Structure of C Program 2) Structure Example
3) Character Handling Functions
Parts:1. Preprocessor directives (#include) struct student {
Functions: isalpha(), isdigit(), isspace(), etc.
2. Global declarations int id;
Used for validating character types.
3. main() function char name[20];
4) String Declaration & Initialization
4. Function definitions };
char str1[10] = "Hello";
3) Features of C Program 3) Unions Example
char str2[] = {'H', 'e', 'l', 'l', 'o', '\0'};
Features: union data {
5) Matrix Multiplication Program Example
Simplicity int i;
for(i=0;i<m;i++)
Speed float f;
for(j=0;j<n;j++)
Portability };
for(k=0;k<p;k++)
Rich library Memory shared among all members.
c[i][j] += a[i][k] * b[k][j];
Modular programming 4) Structures with Pointers
5 Marks Questions
Middle-level language struct student *ptr;
1) Strings
4) Identifiers and Tokens ptr = &s1;
Array of characters ending with \0.
Tokens: Smallest elements in a C program.Types: Keywords, printf("%d", ptr->id);
2) Program for Insert/Delete in Array
Identifiers, Constants, Operators, Special symbols.
// Insert