Difference between revisions of "CSC231 Final Exam 2017"

From dftwiki3
Jump to: navigation, search
(Created page with "--~~~~ ---- <onlydft> <bluebox> <font color="purple">This exam is due on Dec 22nd, at '''4:00 p.m.'''.</font> <br /> This exam is given under the rules of the ''honor code''....")
 
Line 24: Line 24:
 
* Run grep and search for various words in the file:
 
* Run grep and search for various words in the file:
 
   
 
   
  <font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> '''231grep in quote.txt'''
+
  <font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> '''./231grep in quote.txt'''
 
  Believe in yourself! Have faith in your abilities!  
 
  Believe in yourself! Have faith in your abilities!  
 
  Without a humble but reasonable confidence in your own powers  
 
  Without a humble but reasonable confidence in your own powers  
 
  you cannot be successful or happy. --Norman Vincent Peale
 
  you cannot be successful or happy. --Norman Vincent Peale
  <font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> '''231grep faith quote.txt'''
+
  <font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> '''./231grep faith quote.txt'''
 
  Believe in yourself! Have faith in your abilities!  
 
  Believe in yourself! Have faith in your abilities!  
  <font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> '''231grep Faith quote.txt'''
+
  <font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> '''./231grep Faith quote.txt'''
  <font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> '''231grep but quote.txt'''  
+
  <font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> '''./231grep but quote.txt'''  
 
  Without a humble but reasonable confidence in your own powers  
 
  Without a humble but reasonable confidence in your own powers  
  <font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> grep -i believe quote.txt  
+
  <font color="limegreen">231b@aurora </font><font color="blue">~/handout $</font> '''./231grep -i believe quote.txt'''
 
  Believe in yourself! Have faith in your abilities!  
 
  Believe in yourself! Have faith in your abilities!  
  
 
<br />
 
<br />
 
* Your program should behave '''exactly the same way'''.
 
* Your program should behave '''exactly the same way'''.
 
+
<br />
 +
==Implementation Details==
 +
<br />
 +
* Your program needs to support only the "-i" switch
 +
* The order of the command-line parameters will always be
 +
::# switch (if present)
 +
::# word
 +
::# file name
 +
<br />
 +
==Submission==
 +
<br />
 +
* Submit your code on Moodle, in the '''grep''' section of the final exam.
 
<onlydft>
 
<onlydft>

Revision as of 15:28, 29 April 2017

--D. Thiebaut (talk) 16:23, 29 April 2017 (EDT)


<onlydft>

This exam is due on Dec 22nd, at 4:00 p.m..
This exam is given under the rules of the honor code. You have access to all your notes, to books, and to the Web. You cannot, however, discuss the details of the exam with anybody other than your instructor. Questions regarding the exam can only be asked in class, or using Piazza. Do not post code on Piazza. Do not suggest or imply possible solutions in your posts on Piazza. All three problems are worth the same number of points.



Problem 1: C Coding


Write a C program called 231grep.c that works similarly to the Linux grep command. Your program should get its input from the command line, just like grep, and support the "-i" switch. When the user uses this switch, the search is not case sensitive. When the user omits the switch the search is case-sensitive.
Here is an example illustrating how your program should work.

  • Create a text file called quote.txt containing the following 3 lines:


Believe in yourself! Have faith in your abilities! 
Without a humble but reasonable confidence in your own powers 
you cannot be successful or happy. --Norman Vincent Peale
  • Run grep and search for various words in the file:
231b@aurora ~/handout $ ./231grep in quote.txt
Believe in yourself! Have faith in your abilities! 
Without a humble but reasonable confidence in your own powers 
you cannot be successful or happy. --Norman Vincent Peale
231b@aurora ~/handout $ ./231grep faith quote.txt
Believe in yourself! Have faith in your abilities! 
231b@aurora ~/handout $ ./231grep Faith quote.txt
231b@aurora ~/handout $ ./231grep but quote.txt 
Without a humble but reasonable confidence in your own powers 
231b@aurora ~/handout $ ./231grep -i believe quote.txt 
Believe in yourself! Have faith in your abilities! 


  • Your program should behave exactly the same way.


Implementation Details


  • Your program needs to support only the "-i" switch
  • The order of the command-line parameters will always be
  1. switch (if present)
  2. word
  3. file name


Submission


  • Submit your code on Moodle, in the grep section of the final exam.

<onlydft>