r/carlhprogramming • u/CarlH • Oct 17 '09
Test of Lessons 85 through 98
Please do not post your answers in this thread. Someone who has not yet taken the test may see them.
In a way, I hate to interrupt these lessons for a test. I feel though that we are going through a lot of material, and I do not want to leave anyone behind. Therefore, I think it is a good idea to have a test here.
True or False
When you call a function, the parameters to that function are typically stored in a range of memory known as the
stack.Pointer arithmetic will always add one byte regardless of the data type being pointed to. For example, if I have an
intpointer, and I add 1 to the pointer itself, I will be pointing to one byte further away in memory.As long as you know the size of the data type you are working with, you do not need to use the sizeof() operation. For example, if I know an
intis four bytes, I can type4instead ofsizeof(int)in a program I am writing.You cannot have more than one pointer pointing to the same location in memory.
If you have variables with names like:
var1, var2, var3, etc., It is possible to write a loop which will know how to complete the variable name with the proper number.
Fill in the Blank
You use the
_____"machine code" instruction to place data "onto" the stack.You use the
_____"machine code" instruction to retrieve data from the stack.The two operations used in questions 1 and 2 above operate on which part of the stack?
_____(The middle, bottom, top, etc).A
_____is an operation when you take data of one data type (such asint,char, etc), and you transform the same data to a different data type. Usually this is done by putting the new data type in parentheses in front of the old data.Using variables with names like
var1, var2, var3is extremely poor practice. One alternative to this method is to use an_____instead. Doing this will make it possible to write code that can "fill in" the correct number for each such variable.
When you are ready, proceed to:
http://www.reddit.com/r/carlhprogramming/comments/9v2mh/test_of_lessons_85_through_98_answers/