EECS 381 Reading Assignment 1 Yuchen Wen
Chapter 1 A Tutorial Introduction
The author started with the “hello world” program. He wrote how to write, compile and run the code. What I doubt
in this part is that the author use “cc” to compile a c program. What I usually do is to use “gcc” to compile a c
program. I have searched the internet, most people said that on Linux, cc is a link to gcc. The author mentioned that
every program must have a “main” function since it indicates the beginning of the program. He then introduced the
temperature conversion program. He listed many types in C and their ranges. A float number has at least six
significant digits, which was what I did not know before. The indentation is emphasized when the author explained
the use of “while”. Although the indentation did not affect the code, it did affect how easy the code can be read. The
author used the same style when coding, which made the code in the book clear and easy to read. Truncation was
easy to be ignored when coding. 5/9 would result in 0. The use of “printf” was explained clearly. What I did not
know was the use of “%%”. I did not understand what “%% for itself” meant. I also forgot the use of “%6.2f”. The
“6” was the minimum length of the width and “.2” means 2 characters after decimal point. Then the author wrote the
rule of operand. If I add an integer with a float, the integer will be converted to float and then added with the float
number. Next, the temperature program was rewritten and “for” loop was used. Personally, I would like to use for
loop whenever the loop was countable. I seldom used symbolic constants before. However, after the first course and
reading the 1.4 chapter, I realized the importance of symbolic constants. Instead of “magic number”, the symbolic
constant is much easier to understand and can be changed conveniently when it is used in many places. “getchar()”
and “putchar()” were new functions to me. In the File Copying example, c was declared as int so that it was big
enough to hold any value, such as “EOF”. I was not aware of that an assignment could be a part of larger expression.
The code would be much short and elegant. It was as well good to remember that the precedence of “!=” is higher
than “=”. In the character counting program, long is used instead of int so that the range of counting could be larger.
I was surprised to see that the body of the “for” loop was empty. For the empty loop, we still need a null statement to
satisfy the rule. In chapter 1.5.3, it was good to know that ‘\n’ was a single character instead of 2. In 1.5.4, the use of