Questions & Answers for ICS 331 Assignment #1

Question:

This question is for the third program, I'm having trouble converting the clock_t variables into a double format. I have the value of a start time saved as a clock_t format calling the clock() function. But when I try to convert it into a double, I get a really big number. Is it okay if I just print the time elapsed in a clock_t format, which means that the result will show whole numbers only, none with exact decimals. Is that okay or is there another way I could do it?

Answer:

You should get a really big number. Then you have to divide it by CLOCKS_PER_SEC to get the number of seconds.


Question:

For assignment 1, it says that we need a Makefile to build all three of our programs. Does that mean one Makefile total, or one for each program? If it's the earlier, how do you go about doing it?

Answer:

Make your first target in the Makefile a super target such as "all" that lists as its dependencies all of the other programs (binprint, endian, arithtime) and no rules/commands to execute. The make program defaults to build the very first target if none is supplied on the command line. So to build all of the programs, you can either type "make all" or just "make" and to build a particular program, your type "make target_name" (e.g., "make endian").

all: binprint endian arithtime

binprint: ...
	...

endian: ...
	...

arithtime: ...
	...


Question:

Another question is if I can use some c== feature in the program. For example a template function can simplify the question 3 greatly.

Answer:

No, please stick with pure C constructions.


Question:

I used your suggested 100,000 iterations in question 3, but the result is always 0 on my home computer. I guess a Pentium4 3.0GHz is too fast. I changed to a bigger number 10,000,000, then the time is still less than 1 second. My question is "can I use any number I lie?".

Answer:

Yes, please use as many iterations as will give good results. You may want to use fewer iterations on the slower uhunix2 system than on your faster home computer.


Question:

I still have question about signed integers for assignment #1. I found that in the my machine negative numbers stored in one's complement form. Therefore the question is: should the program print integer as it exactly stored in memory or should it use some rules to convert integer to binary?

Answer:

It should print in exactly the form stored on the computer. Do not do any conversion.


Question:

i'm not sure what uhunix2 is.

Answer:

That's the UH ITS Sun Solaris machine on which everybody with UH email has an account. Use ssh to open a UNIX shell on uhunix2 (full address: uhunix2.its.hawaii.edu). There you can run gcc to compile your C programs. Ssh can be downloaded for free from the ITS supported software page. (there's other free software listed there too). Note that ssh is already built into Mac OS X.


Question:

I was wondering if you could suggest a c compiler for windows xp. I couldn't find any that would work on my computer.

Answer:

You can get a free copy of MS Visual Studio from the MSDNAA (I have just sent the class list to the ICS MSDNAA administrator, so you should all get an email soon telling you how to download software like Windows XP for free -- sorry no MS Office) or a free copy of gcc from: Gnu If you are running MS Windows, a fellow student recommended the Cygwin version of the binaries (I have no recommendations either positive or negative for the MinGW version of the binaries): Cywin



Last modified: Tue Sep 6 15:39:09 HST