Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

DSA ASSIGNMENT 1

SUMBITTED TO : Mr. Amit


SUBMITTED BY : Aryan Kushwaha
SAP ID : 500119043
Roll No. : R2142230711
BATCH : 23
YEAR OF STUDY : 1st year
SEMESTER : 2nd Semester
1) Write a function that returns the largest number in a user defined array which is
passed as parameter

2) Write a function to find the binary equivalent of a given decimal integer and display it
3) Explain the concept of function pointer with example

4) Explain the concept of function callback with example


5) Write a C program that demonstrates the concept of dangling pointer. Create a
function to allocate memory dynamically, return a pointer to the allocated memory, free
the memory inside the function, and then attempt to access the memory through a
dangling pointer in the main function. Finally, discuss the consequences of using
dangling pointer and how to prevent or mitigate such issues

6) Given three variables x, y, z write a function using call by reference method to


circularly shift their value to the right. In other words if x = 5, y = 8, z = 10 after circular
shift y = 5, z = 8, x = 10
7) A 3-digit positive integer is entered through the keyboard, write a function to calculate
sum of digits of the 3-digit number

8) Write a function that e iciently merged two sorted arrays into a single sorted array,
utilizing dynamic memory allocation [Ex a = {1, 3, 5} b = {2, 6, 7} output {1, 2, 3, 4, 5, 6, 7}]
9) Write a function to return the total number of 1s in any user defined integer number
passed as parameter to function [Ex input 10 output 2]
10) Write a function using call by reference method to swap two numbers using XOR
gate

11) Write a program to manage an employee payroll system using structures to store
information such as employee ID, name, salary, etc. Implement functions for salary
calculations, deduction, and displaying employee details

You might also like