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

More Examples of Disk File I/O

More Examples of Disk File I/O

The following sections show several more examples of disk file I/O, such as reading and writing binary data and redirecting the standard streams. Three more I/O functions, fscanf(), fprintf(), and freopen(), are introduced, too.

Random Access to Disk Files

Random Access to Disk Files

Exercises : Answer the following Question

To help solidify your understanding of this 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 What are the differences between a text stream and a binary stream?

Reading and Writing Disk Files

Reading and Writing Disk Files