Assignment title: C++
The steps to complete for this question are: 1. Create a svn repository named asn2. 2. Write a C++ source file 'main.cc' with an main() that only returns 0. Commit to SVN repo with proper message. 3. Use TDD to create a math library in files mathlib.h and mathlib.cc (a) add a function 'sum' that calculates the sum of two numbers. sum() should return the sum of the two numbers sent to it. (b) at this point, adding two numbers is okay. But what about adding three numbers? add that functionality as well. (You could use function overloading at this point). (c) now make sum() invariant to the number of arguments. You will find this url useful: http://www.gnu.org/software/libc/manual/html_node/Variadic-Example. html#Variadic-Example 4. Add a string library in the files stringlib.h and stringlib.cc • Add a function bool substringAtOrAfter(char haystack[], char needle[], int pos) that checks if a substring needle appears within a larger string haystack at or after position pos (assume 0-based positions). • Add another function bool isSubstring(char haystack[], char needle[]) that checks if a substring needle appears within a larger string haystack at any position. 5. Your main() should contain the calls to test cases, which should be enabled/disabled by a flag named DEBUG. Use enum for that. 6. You have to write a makefile with at least one implicit rule to compile/link the files in this question. 7. You have to submit your repository as an archive along with the log output in a separate textfile named q1 svnlog.txt 8. Properly comment your code to make them readable. Markers may deduct up to 5 marks for no/insufficient comments. 2 Question 2 After completing Question 1, profile your program with gprof with '-b' option and submit the output in a file named 'q2 profile.txt'. Question 3 1. Write a c++ source file named q3 dec bin.cc that has a function named b10 to b2(long x) that will output the binary representation of a number x. 2. Properly Test your function with different values. Put all the test calls inside main(). 3. submit the output of your program in a file named q3 b10 to b2.txt. Question 4 Write a bash function f1 and declare an associative array arr therein. Call the function with 5 (key value) pairs. Use the (key, value) pairs to populate the array. Finally, print the keys and values in the array separately. And finally show that the size of the array is half of the size of the number of arguments sent to the function. Assume, even number of arguments will be sent to the function. Submit the bash script giving the name 'q4 func array.sh' and submit the call command of the function and the output in a file named 'q4 func array.txt' Question 5 Write a bash script, named 'q5 imgurl.sh', to save the href values of the link tags (hai ... h/ai) from the HTML source of the following page in a file named q5 imgurls.txt:However, you must prepend the string to each href value. You may find curl or wget command useful to download the HTML source of the webpage. Also submit your script