Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C PROGRAMMING Question 1 Assume the following structure definition: struct inven

ID: 3702552 • Letter: C

Question

C PROGRAMMING

Question 1

Assume the following structure definition:

struct inventory
{
    char      part_name[30];
    int         part_number;
    float      price;
};

Which of the following declares variable item to be of type struct inventory:

struct inventory item;

item = struct inventory;

struct inventory = item;

item struct inventory;

question 2

struct date
{
    int month;
    int day;
    int year;
};

Also assume the following variable declaration:

struct date birthdays[5] = {1, 10, 1995, 2, 3, 1996, 7, 21, 1987};

What is the value of birthdays[1].day?

question 3

struct date
{
int month;
int day;
int year;
};

What does the following program output:

#include <stdio.h>
void display_birthday (struct date);
main()
{
     struct date  birthdays[5] = {1, 10, 1995, 2, 3, 1996, 7, 21, 1987};
     display_birthday ( birthdays[0] );

     return 0;
} /* end main */

void display_birthday (struct date d)
{
     printf ("%d/%d/%d", d.month, d.day, d.year);
} /* end display_birthday */

question 4

If I pass the address of a variable to a function, that variable is considered to be passed by ____________.

reference

value

question 5

Pointers can successfully be initialized to the following value: (Select all that apply)

0 (the integer value zero)

An address.

Any value.

Symbolic Constant: NULL

question 6

Assume the following array declaration: int test[3]; How many elements are in this array?

1

3

2

4

a.

struct inventory item;

b.

item = struct inventory;

c.

struct inventory = item;

d.

item struct inventory;

Explanation / Answer

Question 1:

a. struct inventory item;

Question 2:

birthdays[1].day is 3.

Question 3:

1/10/1995

Question 4:

a. reference

Question 5:

a. 0 (the integer value zero)

b. An address.

d. Symbolic Constant: NULL

Question 6:

b. 3