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:
- Define function templates for deposit, withdraw, and
interest calculation
- Accept initial balance
- Use loop to display menu (Deposit / Withdraw / Interest
/ Exit)
- For deposit: validate amount > 0 and update balance
- For withdrawal: check sufficient balance before
deduction
- For interest: calculate based on formula
- Store each transaction in an array
- Display transaction history
- 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:
- Define function templates for sum, average, variance
- Accept array size and elements
- Validate input size
- Compute sum using loop
- Calculate average
- Compute variance using formula
- Calculate standard deviation
- 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:
- Define function template for sorting (e.g., quicksort
or bubble sort)
- Define function template for binary search
- Accept array elements
- Sort array before searching
- Accept search key
- Apply binary search
- Display position if found
- Else display not found
- 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:
- Define function template for sorting marks
- Input student names and marks
- Validate marks range (0–100)
- Sort marks in descending order
- Assign ranks based on sorted order
- Handle equal marks (same rank)
- 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:
- Define function template evaluate(T
coeff[], int n, T x)
- Accept degree of polynomial
- Input coefficients
- Validate inputs
- Use loop to compute polynomial value
- Return result
- 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:
- Define function templates for matrix addition and
multiplication
- Accept matrix dimensions
- Validate compatibility for operations
- Input matrix elements
- Perform addition (if valid)
- Perform multiplication (if valid)
- 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:
- Define function templates for encryption and decryption
- Accept input data
- Apply transformation logic (e.g., shift or XOR)
- Store encrypted data
- Decrypt and verify original data
- 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:
- Define function templates for operations
- Accept expression input
- Parse operands and operators
- Validate expression
- Perform operations based on precedence
- Handle division by zero
- 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:
- Define function template for merging arrays
- Accept two sorted arrays
- Validate input sizes
- Compare elements and merge in sorted order
- Store result in new array
- Display merged array
Comments
Post a Comment