Exercises : Answer the following Question

Submitted by Anonymous (not verified) on Sun, 03/10/2013 - 21:27

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."

What's wrong with the following structure declaration?

    struct automobile {
         int year;
         char model[8];
         int engine_power;
         float weight;
         }


    How many structure variables are defined in the following statement?

    struct x {int y; char z} u, v, w;

    Given a structure declaration

    struct automobile {
         int year;
         char model[8]};

    and two car models, Taurus and Accord, which are made in 1997, initialize an array of two elements, car, that is defined with the automobile structure data type.
    In the following structure declarations, which one is a forward-referencing structure, and which one is a self-referencing structure? (Assume that the structures, employment and education, have not been declared yet.)

    struct member {
         char name[32];
         struct employment *emp;
         struct education *edu;};

    struct list {
         int x, y;
         float z;
         struct list *ptr_list;};

Exercises

    Given the following declaration and definition of a structure

    struct automobile {
         int year;
         char model[10];
         int engine_power;
         double weight;
         } sedan = {
         1997,
         "New Model",
         200,
         2345.67};

 

Related Items

The Dereference Operator (*)

The Dereference Operator (*)

Declaring Pointers

Declaring Pointers

What Is a Pointer?

What Is a Pointer?

A pointer is a variable whose value is used to point to another variable.

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

Question and Answer

    Q How many expressions are there in the if statement?