CS112 : Programming & DS Lab Write a C Program to Implement - IT/Computer Science Assignment Help
Question Task Id: 327355
- University :
SRM UNIVERSITY, Chennai TvAssignmentHelp is not sponsored or endorsed by this college or university.
- Country :
Connect with Assignment Expert Now
If any concept is new to you in this assignment then learn it yourself or google it.
You must clear your doubt by 3:00 pm, 30/06/2021.
Proper indentation is mandatory. (4 marks)
VERY IMPORTANT: You must add comments whenever necessary, to make the code understandable. (6 marks)
Answers files: Source_code file: endsem_1.c, endsem_2.c
After 11:59 pm, 30/06/2021 you can submit over email till 2:00 pm, 01/07/2021 but 30% mark will be deducted. After 2:00 pm, 01/07/2021 no marks will be given. ? No excuse will be entertained for late submission. So submit well in advance.
Q1: Write a C program to implement the grep command in linux. grep command searches for a pattern match in a file. For example grep “Hello” file1.txt will search for the word “Hello” in the file file1.txt. Similarly, grep “Hello” ./* will search for the word “Hello” in all files in the current directory. Implement this grep command with your own code. Take care with the following points. a. The arguments to grep should be fetched as command line arguments. b. The number of files can be variable like this execution: iit@iit-Veriton-Series:~$ grep "Hello" test test1 test:Hello Hello test:Hello 123 test1:Hello test1:Hello 123 iit@iit-Veriton-Series:~$
Q2: Write a C program to implement the following Treasure Hunt game: Suppose you are told to find a diamond hidden in a lake. Your algorithm is very simple. You search randomly in all possible places within the lake until you find it. You start with a random position, generate a random number and add to your current position to get a new position, move to that new position to check whether there is the diamond. If it is there you are done, otherwise you repeat the same process from the present position. You do that until the diamond is found and at last you return the number of times you tried to guess the position. Implement the same considering the lake as a file containing arbitrary data among which there is a single word called “diamond”. Use rand() to generate a random number (may be positive as well as negative) and add to the current position. But take care that only valid moves are possible and you don't cross the file boundaries. For an invalid move you ignore the move and stay at your current position. For the move use fseek() function. Return the number of moves required to search the word diamond. Take the name of the file to search for as a command line argument.
The above CS112 IT Assignment has been solved by our IT Assignment Experts at TVAssignmentHelp. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our experts are well trained to follow all marking rubrics & referencing style.
Be it a used or new solution, the quality of the work submitted by our assignment experts remains unhampered. You may continue to expect the same or even better quality with the used and new assignment solution files respectively. There’s one thing to be noticed that you could choose one between the two and acquire an HD either way. You could choose a new assignment solution file to get yourself an exclusive, plagiarism (with free Turnitin file), expert quality assignment or order an old solution file that was considered worthy of the highest distinction.