$29
Assignment #3
C language programming According to Wikipedia, an anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. For example, the word anagram can be rearranged into nag a ram, or the word binary into brainy. Create a C code program called anagram.c that implements the anagram check. The program should require the user to input 2 words then returns code 0 if the words are anagrams, code 1 otherwise (please note that 0 or 1 should be returned as an integer number of type int). Compile your C code with gcc and make sure that the executable generated by the compiler is called anagram. Create also a BASH shell script called anagram_test.sh that will be used to automate the process of testing the executable created by compiling your C code.
This bash script will be used at the command-line as follows: ./anagram_test.sh
The script will do the following in this order without prompting the user to input anything:
● Clear the screen ● Next, calls anagram by sending it the following 2 words: listen and silent. ● Checks the exit code of the anagram program. If it is zero, print to the screen: test succeeded. If not, print to the screen: test failed. ● Next, calls anagram by sending it the following 2 words: listen and silence. ● Checks the exit code of the anagram program. If it is one, print to the screen: test succeeded. If not, print to the screen: test failed. ● Finally the script terminates by displaying to the screen: “Execution of anagram program has ended successfully!”
Vybihal & Zammar Page 1 of 2 02-05-2019
McGill University COMP 206 School of Computer Science
WHAT TO HAND IN Everything must be submitted to My Courses before the due date. Remember that you can hand in your assignment up to two days late but there will be a penalty of 5% each day. After that, your assignment will not be accepted. Please hand in the following: ● A single Bash script called anagram_test.sh ● A single C code file called anagram.c
HOW IT WILL BE GRADED The assignment is worth a total of 20 points. o 12 points - Anagram C program implementation as follow: ● 2 points for getting the 2 words as inputs ● 2 points for returning the proper exit codes ● 8 points for the anagram algorithm o 8 points for the BASH script as follow: ● 4 points - providing the words to the executable through the bash script ● 2 points - checking the exit code result ● 2 points - displaying the proper messages to the screen
GRADING RULES The following rules are followed by the TA when grading assignments: ● A program must run in order to get a grade (even if it does not run well). If it does not run (does not compile) it will receive a zero. (Make sure to run your programs from Trottier – they sometimes do not run the same from home when logging in using putty.) ● The TA will grade using the mimi.cs.mcgill.ca server. ● All questions are graded proportionally (assuming the program runs at all). This means that if 40% of the question is correct, you will receive 40% of the grade. ● The TA will compile the c code then runs the submitted script and observe the execution. ● The TA may modify the script to provide other words for checking. ● The TA will finally check whether the script displays the messages properly depending on the anagram check result.
Vybihal & Zammar Page 2 of 2 02-05-2019