BU CAS CS 113
Introduction to Computer Science II with Intensive C
Fall 1996


HW1 FAQ

The Assignment

Q. I have a question on hw1-temp.c Do you want us to use integers in the output which will cut off the decimals and comment on it or do you want us to use integers and print out the decimal also? For example: 35 celcius = 1 fah. and commment or 35 celcius = 1.7 fah. and comment?

A. Use integers. Can you think of a way to get 35 celcius = 2 fahrenheit? (This is not reqired, but would be preferable.)

Q. For the first question, you want both temperatures to be integers. Is there a function like ceil() or floor() to work with integers?

A. You should just work with integers. When you get an expression which is floating-point and want to convert it back to an int, use an explicit cast. There are examples of this in the book.

Q. I was wondering if we could use arrays in problem 4 in order to input the integers. And then do a bubble sort to find the largest integer. If we can not use arrays then how many valuse shoud the list be able to contain?

A. You may NOT use arrays. The list should have no a priori length bounds. You do not need to sort, since you only need the largest, which is much easier to find. Read the problem in the book and some of the discussion there in the problems nearby and also in the chapter for some hints on how to do this. We actually did some of this in class the other day.

Other matters (compiling, grading, etc.)

Q. I'm getting compiler warnings. They aren't fatal. I was just wondering if you were penalizing us for any compiler warnings. How strict are you? Are these warnings going to bring down our grades?

A. Warnings are, of course, not nearly so serious as fatal compiler errors. However, warnings are often the sign of a bug, an oversight, or just bad coding practice, thus I want you to pay attention to warnings. The easiest way to ensure that you pay attention to them is to take off some (not much) from your score. The amount will depend on the number and type of warnings.

Q. I tried compiling the first assignment and it gave me some warnings, for example that return-type defaults to 'int'. Isn't this because I did not void the main function? You told us not to worry about it for now.

A. I actually got several warnings when I compiled. Several are due to the fact that you did not use #include for the appropriate header files. (The compiler was nice enough to find the libraries for you anyway, but gave you a warning.) That is the kind of warning which will cost you a point or two.

The other two warnings (including the one mentioned in the question above) come from something we will discuss in class on Thursday, September 12. Do not worry about them for now. If you want to fix it, change the line with

 
		main() 
to
		int main()
and put the line
		return(0);
as the last line in the body of main. I'll tell you why and what this means on September 12.

Q. How do I use the "Makefile" for HW1?

A.

Please make sure that you can compile your HW1 programs using our Makefile. Using netscape, go to the web page that has the description for HW1. Choose the link that goes to the "Makefile". While viewing this Makefile, choose "Save As..." from netscape's "File" menu. It will want to save the file as "Makefile.a1". Click on Ok.

Your must rename the file using the move command, at the UNIX prompt:

    mv Makefile.a1 Makefile

Also, you must make sure the Makefile is in the same directory as you program files. If not, you will have to move the Makefile there. For example, if your files are in "hw1", you may need to do:

    mv Makefile hw1

At the UNIX prompt, make sure you are in the directory with the Makefile and your source files, type:

    make

It should create the files: hw1-temp, hw1-weight, hw1-sum, hw1-stats without any errors (if you've correctly written the programs).

Run each of them to make sure they work.

Don't forget to "submit" your source code when you are done and your programs work (as we did in discussion).

-Rob

Q. I cut the Makefile into Emacs and saved it, but it doesn't work.

A.

You need to use the saving procedure I mentioned above to save the Makefile. We have not had time this week to go into details of the Makefile (we will next week), but commands in the Makefile that generate files, like:

        $(CC) $(CFLAGS) -c hw1-temp.c

have to begin with the TAB character. When you cut and paste often, TABS get turned into SPACES and thus the Makefile will no longer work. Saving the Makefile via netscape as previously mentioned will keep the TABS as TABS.

-Rob


Last update: 11 Sep 1996