In the tutorial of assignment 3, two methods are provided for reference. I chose method B, using Zeller's congruence for the Gregorian calendar to calculate the day of the week in the program.
At the beginning stage, we mainly used char, int and float in writing programs. In this chapter, we learnt all fundamental data types as shown below. They are classified into two types, Integral Types and Floating Types. For the presence of Integral types and Floating types in the same time, this is called Arithmetic Types.
Besides, the 7-bit ASCII Table has been introduced. ASCII stands "American Standard
Code for Information Interchange". It includes some printable characters: 'A', '=', ':', ... and some non-printable characters: newline (NL), bell (BEL), tab (HT, VT), ... ASCII indicates the different values stored in one byte of each character. One byte equals 8 bits, which has 2 to the power 8 possibilities, 256 distinct values can be represented. Therefore, the full range of value is 0 - 255, ASCII uses 0 - 127 only.
For some non-printing or hard-to-print characters in ASCII, we write them with escape character (\) in C, instead of typing them directly, and it is called escape sequence.
On the other hand, I have learnt an interesting topic, Function. To use it, we need to define a function then we can call and execute it afterwards. It is very useful in writing programs, as illustrated below, the program can be simplified by calling a function, instead of using printf("*****************\n") one more time.
The following is another example similar to the above one, we can divided the function helping us to count the number of symbols we want to print out. By this method, we can save our time in counting the number of symbols and counting error can be prevented.
Apart from this, there are many different types of function, below are the examples of Math function. They help us to perform mathematical functions such as exponential function, absolute value, and even logarithm an d trigonometric functions.
0 comments:
Post a Comment