Lab 1
Lab 1
Target: CLO-1
CLO 1 2 3 4 5
CLO-1 2-marks for 2-marks for 2-marks for 2-marks for 2-marks for
task1 task2 task3 task4 task5
Task: 1
Define a structure named Employee with members for employee ID, name, and salary.
Create a function named InitializeEmployee that takes a reference to an Employee structure and
initializes its members with values provided by the user. Write a function named FindMaxSalary that
takes an array of Employee structures and its size as parameters. The function should find and return
the employee with the maximum salary.
Create a function named CalculateAverageSalary that takes an array of Employee structures and its
size as parameters. The function should calculate and return the average salary of all employees.
Write a function named UpdateSalary that takes an Employee structure and a percentage increase as
parameters. The function should update the salary of the employee based on the provided
percentage increase.
• Call the FindMaxSalary function to find and print the details of the employee with the
maximum salary.
Task: 2
Write a function that will take two pointers of integer arrays of fixed size. The function will return 0 if
both the arrays are same and return -1 otherwise. Call the function from main to check its
functionality. The function declaration is given below:
Task: 3
Implement a C++ program that explores various string operations without utilizing the cstring library.
Your task is to create the following functions: Calculates the length of a given string. Concatenates
two strings. Compares two strings. Copies the content of one string to another.
Ensure your program handles user input appropriately, and limit the length of input strings to
prevent buffer overflow.
Task: 4
Write a C++ program that creates and initialize 3 variables of different types, create pointers for each
variable and access those variables using pointer references and show memorysize of each variable
using (sizeof ()) function.
Task: 5
Handling Upper Limits in C++
Write a C++ program that prompts the user to input a number within a specified range. Implement
the following:
1. Set a lower limit (LOWER_LIMIT) and an upper limit (UPPER_LIMIT) for the allowed input range.
2. Use a while loop to repeatedly prompt the user until a valid input within the specified range is
provided.
3. If the user enters an invalid input (not a number or outside the specified range), display an error
message and prompt again.
You are not allowed to use the <limits> library for this task. Test your program with different inputs
to ensure it handles upper limits correctly.