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

Birla Institute of Technology & Science, Pilani Computer Programming (CS F111) Second Semester 2011-2012 Lab-10

______________________________________________________________________________ Topics: Review on a) Arrays b) Functions ______________________________________________________________________________ Attempt the following questions to review what you have learned up to now: Q1. Implement the following functions / procedure: a) Implement a procedure which reads two strings from the user as input. b) Implement a function named substring. This function takes as input two strings and decides whether the second string is a substring of the first one. It returns 0 if the second string is not the substring of the first one, else returns the position of the first occurrence of the second string. [Note: Do not use the library function substr(). End of Note.] c) Implement a function, named trim(), which takes one string and an integer (say NOC) as parameters. It deletes the first NOC characters from the string (in-place). Call the above functions from main in proper order to find all the occurrences of a string in another string. Q2. Write a C program to implement the following. The program asks the user to input an integer list one integer after another separated by space. This list may contain multiple occurrences of elements. The program then can perform the following task repeatedly (you can repeat it until user enters a character 'N'): "User inputs an integer. The program deletes all the occurrences of it from the array and shifts the elements so that the remaining elements are stored contiguously in the array. Display the remaining elements".
[Note: First divide the task in proper order and identify the required functions. Show it to your instructor and then start the implementation.]

You might also like