EX NO 8B: OOPS LAB - FUNCTION TEMPLATE

 

EX NO 8B:Function Template

1. Multi-Type Banking Transaction Analyzer ( RNO – 1 TO 5)

Problem Statement:
Design a program using function templates to perform multiple banking operations (deposit, withdrawal, interest calculation) for different numeric data types. Maintain transaction history and validate all operations.

Steps:

  1. Define function templates for deposit, withdraw, and interest calculation
  2. Accept initial balance
  3. Use loop to display menu (Deposit / Withdraw / Interest / Exit)
  4. For deposit: validate amount > 0 and update balance
  5. For withdrawal: check sufficient balance before deduction
  6. For interest: calculate based on formula
  7. Store each transaction in an array
  8. Display transaction history
  9. Repeat until user exits

2. Generic Data Analyzer System ( RNO – 6 TO 10)

Problem Statement:
Develop a program using function templates to analyze a dataset (array) by calculating sum, average, variance, and standard deviation for different data types.

Steps:

  1. Define function templates for sum, average, variance
  2. Accept array size and elements
  3. Validate input size
  4. Compute sum using loop
  5. Calculate average
  6. Compute variance using formula
  7. Calculate standard deviation
  8. Display all statistical results

3. Generic Sorting & Searching System ( RNO – 11 TO 15)

Problem Statement:
Create a program using function templates to perform sorting and binary search on arrays of different data types.

Steps:

  1. Define function template for sorting (e.g., quicksort or bubble sort)
  2. Define function template for binary search
  3. Accept array elements
  4. Sort array before searching
  5. Accept search key
  6. Apply binary search
  7. Display position if found
  8. Else display not found
  9. Allow repeated operations

4. Student Ranking System ( RNO – 16 TO 20)

Problem Statement:
Implement a program using function templates to rank students based on marks and handle tie conditions.

Steps:

  1. Define function template for sorting marks
  2. Input student names and marks
  3. Validate marks range (0–100)
  4. Sort marks in descending order
  5. Assign ranks based on sorted order
  6. Handle equal marks (same rank)
  7. Display ranked list

5. Generic Polynomial Evaluation System ( RNO – 21 TO 30)

Problem Statement:
Develop a program using function templates to evaluate a polynomial for a given value of x for different numeric types.

Steps:

  1. Define function template evaluate(T coeff[], int n, T x)
  2. Accept degree of polynomial
  3. Input coefficients
  4. Validate inputs
  5. Use loop to compute polynomial value
  6. Return result
  7. Display output

6. Multi-Dimensional Matrix Operations ( RNO – 31 TO 40)

Problem Statement:
Design a program using function templates to perform matrix addition and multiplication for different data types.

Steps:

  1. Define function templates for matrix addition and multiplication
  2. Accept matrix dimensions
  3. Validate compatibility for operations
  4. Input matrix elements
  5. Perform addition (if valid)
  6. Perform multiplication (if valid)
  7. Display results

 

7. Generic Encryption System ( RNO – 41 TO 50)

Problem Statement:
Develop a program using function templates to perform simple encryption and decryption on different data types.

Steps:

  1. Define function templates for encryption and decryption
  2. Accept input data
  3. Apply transformation logic (e.g., shift or XOR)
  4. Store encrypted data
  5. Decrypt and verify original data
  6. Display results

8. Multi-Type Expression Evaluator ( RNO – 51 TO 55)

Problem Statement:
Implement a program using function templates to evaluate arithmetic expressions with multiple operators for different numeric types.

Steps:

  1. Define function templates for operations
  2. Accept expression input
  3. Parse operands and operators
  4. Validate expression
  5. Perform operations based on precedence
  6. Handle division by zero
  7. Display result

9. Generic Data Merge System ( RNO – 56 TO 61)

Problem Statement:
Create a program using function templates to merge two sorted arrays of different data types into a single sorted array.

Steps:

  1. Define function template for merging arrays
  2. Accept two sorted arrays
  3. Validate input sizes
  4. Compare elements and merge in sorted order
  5. Store result in new array
  6. Display merged array

Comments