Matrices Top Footnotes Contents


It seems odd that the compiler does not know about a function it should know about, since printf is built in. But C was designed to be a rather flexible language, so we will need to inform the compiler properly for reasons not worth going into at this time.
On Linux and other Unix-like systems, the standard header files are located in the /usr/include/ directory.
Executed is such a gruesome term, but it means run or performed. It derives from the idea of an executive performing the task indicated by the line of code.
More on command-line arguments in a later chapter.
Languages that do not allow changes to a variable are called functional languages, while those that do are called imperative languages. C is an imperative language.
Another fundamental concept of Computer Science is analogy and if you understand the purpose of the envelope story after reading this section, you're well on your way to being a Computer Scientist!
The third great fundamental concept in Computer Science is generalization. In particular, Computer Scientists are always trying to make things more abstract and more general (but not overly so). The reason is that software/systems/models exhibiting the proper levels of abstraction and generalization are much much easier to understand and modify. This is especially useful when you are required to make a last second change to the software/system/model.
Even the envelope metaphor can be confusing since it implies that two variables having the same value must each have a copy of that value. Otherwise, how can one value be in two envelopes at the same time? For simple literals, copying is the norm. For more complex objects, the cost of copying would be prohibitive. The solution is to storing the address of the object, instead of the object itself, in the envelope. Two variables can now "hold" the same object since it is the address is copied.
We will cover this in more detail in the chapter on Scope.
In the algebraic equation mx + b, the multiplication sign is elided, but most programming languages, C included, require the presence of the multiplication sign, For C, the multiplication sign is the asterisk.
The believed value of PI has changed throughout the centuries and not always to be more accurate (see )
Actual addresses of memory locations in C are usually large numbers, typically displayed in octal or hexadecimal, rather than decimal.
The value is not really random. A better description would be detritus, the stuff left over from previous activities. The actual value found in an uninitialized variable are the bits left over from previous programs that used that memory location.
Computer Scientists, when they have to write their annual reports, often refer to the things they are reporting on as darkspace. It's always good to have a lot of darkspace in your annual report!
As you get more sophisticated in your C programming, you will likely take advantage of cpp, the C pre-processor. Using cpp, you can add constants to your C program.
Bits in the informal sense, not zeros and ones.
Not all data structures have this property of quick access to data. However, these other data structures, which you will learn about later, may have advantages over arrays in certain situations. Choosing the correct data structure for solving a problem is most of the work in crafting a solution.
There is one exception. Sometimes you will see an array created like this:

int x[512] = { 0 };

C, if given at least one initializer, will set all slots that are missing initializers to zero. This quirk of C makes it quite easy to initialize an array to all zeros.

A byte is eight bits. An integer is usually 4 or 8 bytes, depending on the system, while a double is usually 8 bytes.
Back in the day, when we wanted to look up the meaning of a word, we grabbed a dictionary that had been stored in the form of a book. A book was a device made of something called paper, which, more often than not, was made of pine trees.
The information that is passed into a function is collectively known as arguments. The arguments are then bound to the variables or formal parameters that are found after the function name in the function definition.
Many times, the printing is done to a file, rather than the console.
For variadic functions, which C allows for, the number of arguments may be more than the number of formal parameters. The built-in function printf is a variadic function.
We will learn about loops in the next chapter.
C doesn't care, but your instructor certainly does!
In more modern versions of C, one can use the "%ms" directive and pass in the address of an uninitialized string pointer. In this case, scanf would dynamically allocate a sufficiently large character array, fill it, and set the pointer to point to the array. The caller of scanf would be responsible for freeing the array.
You will often see the term variable declaration instead of variable definition.
We will see the utility of the counting pattern for lists, for which we do not need the size, a priori.
The superior student will ascertain why this is so.
This happens if adding the last element causes the array to grow.
The readTokens function is more complex, but its complexity arises from the desire to not know the number of tokens in advance.
We can't use the alias Node yet, since the alias is set up once the entire node structure is processed. So inside the structure, we must use struct node.
This curious behavior is the basis for a somehting called a stack. You will learn about stacks in your next CS course.
When two variables, in this case a and items, point to the same thing, they are said to be aliases of one another.
Prepend is rather an awkward term, so that is why we will use join as the function name, rather than prepend.
The test condition of the while loop is the reason for the comment that the length of listA must be greater than zero.
Sometimes, destructive functions return a value for convenience to the caller, in which case this generalization fails.
Again, when an operation does not affect its operands, it is said to be non-destructive. The getListIndex function, since it never sets a pointer in the given list, is non-destructive
This idea of repeatedly inserting items in a list with the list remaining ordered is the basis for an important data structure, the priority queue. Priority queues are used in network connectivity algorithms and discrete-event simulations. You will learn about priority queues in a subsequent class
Actually, reversing the logic of greater than yields less than or equal, but we are ignoring situations when values match exactly. What happens in those cases is left as an exercise.
Mathematicians, being an inclusive bunch, like to invite zero to the factorial party.
Ellipses are the three dots in a row and are stand-ins for stuff that has been omitted.
If one views more multiplications as more complex, then, clearly, computing the factorial of n-1 is simpler than computing the factorial of n.
We'll see why the variable temp is needed in the next chapter.
A pineapple, the golden ratio, a chambered nautilus, etc.
13 is 7th Fibonacci number and seven is one more than six. A coincidence? Maybe...or maybe not!
The word is recurs, not recurses!
Yes, division is just repeated subtraction, just like multiplication is repeated division.
The loop variable is considered a outside variable changed by the loop.
A style of programming that uses no assignments is called functional programming and is very important in theorizing about the nature of computation.
Unfortunately, C is not a good language in this regard, but the language Scheme is. When the value of a recursive call is immediately returned (i.e., not combined with some other value), a function is said to be tail recursive. The Scheme programming language optimizes tail recursive functions so that they are just as efficient as loops both in time and in space utilization.
A three-dimensional array would be an array whose elements are arrays whose elements are arrays. Arrays of two dimensions and higher are known as multi-dimensional arrays.
This choice of the backbone representing the rows is purely arbitrary, but when this choice is made, the matrix is said to be row-ordered. If the opposite choice is made, that the backbone represents the columns, then the matrix is said to be column-ordered. Most programming languages provide row-ordered multi-dimensional arrays.

Matrices Top Footnotes Contents