Final Flashcards Preview

CS 130 > Final > Flashcards

Flashcards in Final Deck (39):
1

T/F? A pointer variable must be declared specific to the data type of the variable whose address will be assigned to it.

True

2

T/F? A pointer has as its value a signed integer that is allocated four bytes of storage.

False

3

T/F? To assign the address of a variable to a pointer variable an address operator must be used.

True

4

T/F? To access the contents of a variable through a pointer variable, the pointer variable must be assigned the memory address of the variable first, and then the pointer must be dereferenced.

True

5

T/F? A pointer variable has no data type of its own.

False

6

T/F? A pointer variable must contain an unsigned integer so it cannot point to a character string.

False

7

T/F? A pointer variable must not be assigned a scalar constant.

True

8

T/F? A pointer variable can be added to another pointer variable.

False

9

T/F? A pointer variable can be subtracted from another pointer variable.

True

10

T/F? A pointer variable can be used to change the address of an array.

False

11

T/F? Two pointer variable can point to the same variable.

True

12

T/F? An array name is an address variable.

False

13

T/F? The address of an array is found as either the array name or the explicit address of the first element of the array.

True

14

T/F? The elements of a one-dimensional array may be accessed by dereferencing the offset address only once.

True

15

T/F? To input data to an array using a pointer variable, the name of the array may be used to specify the address of the array elements.

False

16

T/F? To input data to an array using pointer variable, the name of the array may be used to specify the address of the array elements.

True

17

T/F? Arithmetic operations may be performed by using an array name without dereferencing the name.

False

18

T/F? An array can be copied y assigning the address to a pointer variable.

False

19

T/F? The dynamic storage allocation functions are in the sodlib.h header file in C.

True

20

T/F? To allocate a block of storage at the time of execution of the program, dynamic storage allocation functions are used.

True

21

T/F? The pointer tot he dynamic storage returned by calloc() must be cast to the data type it is pointing to.

True

22

T/F? When a dynamic pointer is incremented by one, the address is incremented by the number of bytes of the data type it is pointing to.

True

23

T/F? When a dynamic pointer is incremented, the address of the dynamic pointer variable will change.

False

24

Write the code to declare a dynamic pointer and allocate storage to store a one-dimensional array of 200 elements and data type int.

int *ptr;
ptr = (int *) calloc(200, sizeof(int));

25

Write the code to declare a dynamic pointer and allocate storage to store a one-dimensional array of 80,000 elements of data type float.

float *ptr;
ptr = (float *) calloc(80000, size of(float));

26

Write a program to declare a dynamic pointer and allocate storage to store a two-dimensional array of 50 x 60 of data type float. Also write the code to input data to the dynamic array and output the data from the dynamic array.

float *ptr;
ptr = (float *) calloc(50 * 60, sizeof(float));
{
scans("%f", ptr);
ptr++;
}
ptr = ptr - 3000;
for(k = 0; k < 3000; k++)
{
printf("%f", *ptr);
ptr++;
}

27

T/F? If there is not much variability in length of the character strings they may be stored in smooth arrays.

True

28

T/F? To store strings with large variability in their length, dynamic storage should be used.

True

29

T/F? The dynamic storage allocation function malloc() may be used to allocate storage to store strings.

True

30

T/F? A particular structure is a derived data type derived from the basic and derived data types.

True

31

T/F? When a structure is declared without a structure tag, a storage template is set up to allocate storage for the structure variables.

False

32

T/F? When a structure is declared without a tag, the structure variables must be declared in the structure declaration statement itself.

True

33

T/F? When a structure is declared with a structure tag the programmer has a choice of declaring the structure variables in the structure declaration itself or in a separate statement using the structure tag.

True

34

T/F? Structure variables may be initialized in the structure declaration statement itself.

True

35

T/F?Structure variables may be assigned values by using assignment statements.

True

36

Structure variable members may be assigned values by computations.

True

37

Structure variables may be elements of an array.

True

38

Structure variables are manipulated by using the member operator.

True

39

Structure variables may not be manipulated by using the structure variable pointers.

False