Due: November 9, 2015
Note about points. If you submit this by Wednesday, November 4, at 11:55pm, we will add 20 points to whatever score you receive. If you submit this by Friday, November 6, at 11:55pm, we will add 10 points to whatever score you receive.
All these questions are to be answered using the CSIF systems. If you use some other system, your answers may differ, and we will grade based on the CSIF systems.
|You must put your answers in a file called “Linux.txt” or “Linux.pdf”. If you need to submit pictures also, put them in files called “Linuxn.ext”, where n is a digit and ext is an appropriate extension. If you call your file(s) anything else, or submit something other than text or a PDF file, we will not grade it and you will get 0!|
Please do either of the two questions. You must pick one; you cannot do part of one and part of the other. In your submission, state which one you have done.
If you do question 4, you must submit a file called “MyProgLab.ext”, where ext is any 3-letter extension. We will not look at the contents of this file; its presence tells us you did the MyProgrammingLab exercises.
If you do question 5, you must put your answers in a file called “CPL.txt” or “CPL.pdf”. If you call your file(s) anything else, or submit something other than text or a PDF file, we will not grade it and you will get 0!
|You must put your function in a file called “getint.c”. Do not include a driver (main() routine). If you call your file anything else, or submit something other than a C program (for example, a text or PDF file containing the code), we will not grade it and you will get 0!|
We define an integer as follows:
So for example, “1234”, “ 1234 ”, “1234.”, “ +1234 ”, and “ -1234 ” are all integers, and none of “1234e5”, “e1234”, “1234.56”, and “1234abc” are.
For the purposes of this function, assume that the next line of input was read into an array, for example by fgets, before your function is called. Your function is to have the interface
int getint(char *inputline, int *value, char **nextchar)
The character pointer inputline points to the input line. Generally, your function is to return the number read in the location that value, and the address of the first character after the last digit of the integer is stored in the location pointed to by nextchar.
Your function is to be in a file called “getint.c”.
Hint: Think back to the “if argument n is invalid” comment in assignment 2 problem 6. In a similar way, the arguments passed into this function could be invalid. Use what you have learned in lectures 9–14 about pointers, arrays, strings, and buffers, to think about how these arguments could be given invalid values, and how to detect those invalid values.
Hint: The maximum positive integer is represented by the macro INT_MAX, and the minimum negative integer is represented by the macro INT_MIN, both of which are defined in the include file “limits.h”.
Hint: There is a file that provides an interface (a main routine) available on SmartSite; it is called “getintdriver.c” and is on the CSIF at “/home/bishop/ecs30/getintdriver.c”. If you download it and compile it with your function (see Compiling and Executing Your Program for details on how to do this, but use the file names in this problem), you can focus on writing the function. Also, we have supplied the input files that Gradebot uses. These are available on the CSIF as “/home/bishop/ecs30/hw3-6-input/n”, where n is a number between 1 and 10 inclusive.
|You must put your function in a file called “calc”. If you call your file anything else, or submit something other than a C program (for example, a text or PDF file containing the code), we will not grade it and you will get 0!|
|You can also obtain a PDF version of this.||Version of November 1, 2015 at 1:44PM|