Exercises : Answer the following Question

Submitted by tushar pramanick on Fri, 03/08/2013 - 00:42

To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson. The answers and hints to the questions and exercises are given in Appendix E, "Answers to Quiz Questions and Exercises."

    How can you obtain the left value of a character variable ch?
    In the following expressions, does the asterisk (*) act as a dereference operator or as a multiplication operator?
        *ptr
        x * y
        y *= x + 5
        *y *= *x + 5
    Given that x = 10, the address of x is 0x1A38, and ptr_int = &x, what will ptr_int and *ptr_int return, respectively?
    Given that x = 123, and ptr_int = &x after the execution of *ptr_int = 456, what does x contain?

Exercises

    Given three integer variables, x = 512, y = 1024, and z = 2048, write a program to print out their left values as well as their right values.
    Write a program to update the value of the double variable flt_num from 123.45 to 543.21 by using a double pointer.
    Given a character variable ch and ch = `A', write a program to update the value of ch to decimal 66 by using a pointer.
    Given that x=5 and y=6, write a program to calculate the multiplication of the two integers and print out the result, which is saved in x, all in the way of indirection (that is, using pointers).

Related Items

The #define and #undef Directives

The #define and #undef Directives

The #define directive is the most common preprocessor directive, which tells the preprocessor to replace every occurrence of a particular character string (that is, a macro name) with a specified value (that is, a macro body).

The C Preprocessor Versus the Compiler

The C Preprocessor Versus the Compiler

One important thing you need to remember is that the C preprocessor is not part of the C compiler.

What Is the C Preprocessor?

If there is a constant appearing in several places in your program, it's a good idea to associate a symbolic name to the constant, and then use the symbolic name to replace the constant throughout the program. There are two advantages to doing so. First, your program will be more readable.

Exercises : Answer the following Question

To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson.

Question and Answer

    Q Why is random access to a disk file necessary?