Basic Algorithms
Sum of Two Numbers
Pseudo Code:
- Read
- Print
Implementation (C):
#include <stdio.h>
int main() {
int a, b, sum;
printf("Enter two numbers: ");
scanf("%d %d", &a, &b);
sum = a + b;
printf("Sum = %d\n", sum);
return 0;
}Sum of m Numbers
Algorithm:
- Read
numbers - Initialize
- For
to : - Print
Matrix Sum - 2D Array
Algorithm:
- Read
(dimensions of matrix) - Initialize
- For
to : - For
to : - Read
- Read
- For
- Print
Recursion: Factorial
Recurrence Relation:
Algorithm Properties
- Input: Zero or more inputs
- Output: At least 1 output
- Efficiency: Minimal time and space complexity
Topics to Cover
- Prime Checkers
- Fibonacci Number