School of Computer Science, McGill UniversityCOMP-206 Introduction to Software Systems, Winter 2020Mini Assignment 6: C Programming - Dynamic MemoryThis is an individual assignment. You need to solve these questions on your own. Use the discussionforum on Piazza if you have any questions. Late penalty is -5% per day. Even if you are lateonly by a few minutes it will be rounded up to a day. Maximum of 2 late days are allowed.This assignment will be worth 8% of your overall grade, unlike the other assignments that wereworth only 4%.You MUST use mimi.cs.mcgill.ca to create the solution to this assignment. You must not use yourMac command-line, Windows command-line, nor a Linux distro installed locally on your laptop. You can ssh orputty from your laptop to mimi.cs.mcgill.ca. All of your solutions should be composed of commands that arecompilable/executable in mimi.cs.mcgill.ca.Questions in this exercise requires you to turn in a number of files (will be listed in the description below).Instructors/TAs upon their discretion may ask you to demonstrate/explain your solution. No points are awardedfor commands that do not execute at all or programs that do not compile in mimi. (Commands/programs thatexecute/compile, but provide incorrect behavior/output will be given partial marks.). All questions are gradedproportionally. This means that if 40% of the question is correct, you will receive 40% of the grade.Please read through the entire assignment before you start working on it. You can loose up to 3points for not following the instructions.Unless otherwise stated, all the names of the scripts and programs that you write, commands, options, inputarguments, etc. are implied to be case-sensitive.Total Points: 20Ex. 1 — A Polynomail Evaluation AppIn this exercise, you will create a C modules based program, polyapp to implement a simple application thatconstructs a polynomial expression and evaluates it for certain predetermined values.The polyapp application will receive a text file as input, that contains multiple lines of data to construct a polynomial.Each line will contain the coefficient and exponent of a term in the polynomial. For example, below is an examplefile that represents the polynomial 12xHere 12 and 3 are the coefficient and exponent of the term 12x3, respectively, and so forth.You can use vi to create a data files of your own for testing purposes.1.Create a directory for this assignment and initialize with git (just a local repository, do not make it public).As you progress through this assignment, you will keep commiting code to git (I leave the actual points indevelopment where you feel like you should commit the code to git up to you, but there should be at least4 commits separated out by 15 minutes or more).2.All your program files should include a comment section at the beginning that describes its purpose (couple oflines), the author (your name), your department, a small “history” section indicating what changes you did onwhat date. The code should be properly indented for readability as well as contain any additional commentsrequired to understand the program logic.13.Your main will be in a C file polyapp.c. Your program will be invoked as follows by passing a data file as itsargument. (Therefore, do not assume the name of the data file, but read it from the argument).$ ./polyapp polydata.csvAlthough mini tester will not do any negative test cases by invoking the program with no file names as argumentetc., I highly encourage you to include such logic in your program so that it is easy for you to develop and debugyour program.4.In your main, use fgets to read one line at a time from the data file.5.Use vi to create a C file, utils.c.Create a function parse that accepts a string, and two integer pointers as its argument. Your main will usethis parse function to parse a line that was retrieved using fgets and store the coefficient and exponent to theaddress provided in the integer pointers.Create a function powi that accepts two integers as argument (x and exponent) it returns an integer which isx raised to the power of exponent. For example, if it is passed 2 and 3, it will return 8, which is 23. You mustnot use math.h to perform this. Write your own simple loop to do the computation.6.Create a C file poly.c. Here you will make a linked list that can be used to store a polynomial of arbitrarylength. Your linked list must use the following structure for its nodes.struct PolyTerm{int c o e f f ;int expo ;struct PolyTerm ∗ nex t ;} ;You will need a global variable, head, in this C file to keep track of the polynomial linked list. This C file willneed a minimum of the following three functions (you are recommended to have more, as needed, to make yourprogram modular and easy to develop and debug).addPolyTerm is a function that accepts two integer arguments (a coefficient and exponent) and assimilates thatterm into the existing Polynomial. It returns an integer as its return value. A 0 return indicates success and a-1 for failure (as in for example, ran out of memory, so could not add a new node to the polynomial linked list).displayPolynomial is a function that accepts no arguments and has no return. It will display the polynomialexpression (will see the format later).evaluatePolynomial is a function that accepts an integer value for x and returns an integer that is obtained byevalu代写COMP-206作业、代做Software Systems作业、代写C++语言作业、代做C/C++编程作业 代写Pyating the polynomial. This function will have to traverse the linked list, getting the values for coefficientand exponent from each node and using the powi function to perform computations.7.Have your main parse each line of the data file to extract the coefficient and exponent and add it to thepolynomial using the addPolyTerm function. If you run out of memory (the tester has no test cases for this),print an appropriate message and terminate your program from the main.8.When all the polynomial terms are read and the polynomial is fully constructed, the main should call displayPolynomialto print the polynomial expression to the screen (format will be specified below).9.Next, the main should call evaluatePolynomial for the values (-2, -1, 0, 1, -2) in that order and print theresults (format will be specified below).10.You may need additional header files (.h) to make sure your various C files can interact with each other. Createthem as necessary and include them in appropriate files as needed. The objective is that make / gcc should notgive any compilation warnings and errors.11.Create a make file, name it Makefile . This make file should contain necessary compilation steps to build yourfinal executable, which should be named polyapp. Your program should build an executable if TAs downloadyour source code into an empty directory and just typed make . Therefore, make sure whatever commands youinclude in your make file is not your custom scripts, aliases, etc., but regular commands available to everyonein mimi.Point distribution1.(1 Point) For writing comments on all of your files.22.(2 Points) Turn in your git log, by redirecting its output and store it to a file gitlog.txt. It should show atleast 4 commits which are separated by at least 15 minutes or more.3.(2 Points) For compiling properly with the make command. The make file should be written in such a waythat it compiles only the files that are “changed” and files that are dependant on that changed file (and soforth).4.(1 Point) Proper use of header files to provide as well as limit the exposure of functions and variables to otherC files.5.(6 Points) For displaying the polynomial. The polynomial should be printed in the increasing order of theexponents. You can incorporate the logic to store the terms in sorted order in the linked list as and when youare adding each term into the polynomial linked list.$ cat data1.ssv12 30 24 5$ ./polyapp data1.ssv0x2+12x3+4x5for x=-2, y=-224for x=-1, y=-16for x=0, y=0for x=1, y=16for x=2, y=2246.(4 Points) For merging polynomial terms with the same exponent. You will have to incorporate this logicwhen you are adding each term into the polynomial linked list one-by-one. (You may still display polynomialterms whose coefficient evaluates to 0 as such and is not necessary to remove them).$ cat data2.ssv$ ./polyapp data2.ssv3x0-1x2+12x3+4x5for x=-2, y=-225for x=-1, y=-14for x=0, y=3for x=1, y=18for x=2, y=2237.(4 Points) For correct evaluation of polynomial expression for different values.All coefficients will be whole number integers (-negative through zero to positive). All exponents will be wholenumbers (zero through positive integers).** Important ** If your program “hangs” / is stuck while executing it through the tester script and requires TAsto interrupt it, you will loose 4 points.WHAT TO HAND INTurn in the make file Makefile, your git log gitlog.txt, C program source codes polyapp.c, poly.c, and utils.cnamed properly AS WELL AS any header files (.h) that your program needs to compile correctly. You do nothave to zip the files. The files must be uploaded to mycourses. If you zip your files, double check to ensure that theyare not accidentally corrupted. DO NOT turn in the executable polyapp or your testing data files. TAs will compileyour C program on their own as indicated in the problem descriptions above.3MISC. INFORMATIONThere is a tester script mini6tester.sh that is provided with the assignment that you can use to test how yourprogram is behaving. TAs will be using the exact same tester script to grade your assignment.$ ./mini6tester.shHowever, it is recommended that when you start writing your program, test it yourself first with the aboveexamples. Make a test case for each scenario by creating your own data files that have the format mentioned above.Once you are fairly confident that your program is working, you can test it using the tester script.You can compare the output produced by running the mini tester on your C program to that produced by themini tester on the solution programs which is given in mini6tester.out.txt.Please note that, the output of test cases 1 and 2 might be different based on the header files you have created.We have not included a sample of this test case as it will give away the solution part. The tester script will try tochange the timestamp of every C and H files in your directory in an attempt to figure out how your make file works.Therefore, if you have any C or header files that you are not incuding for your assignment (such as backup files), Irecommend moving it to a different directory (Even a sub-directory) before running the mini tester script to ensureit works the way it will when TAs run it. You should not receieve any erros and warnings from make when minitester runs it if you have written a proper make file.4转自:http://www.6daixie.com/contents/13/5057.html