exam 3

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

typedef struct gameboard { char board[ROWS][COLS]; } GameBoard; GameBoard gameBoard; Given the source code above, which of the following code examples is the correct methodology to pass struct GameBoard variable gameBoard to a function as a pointer? initializeGameBoard(&gameBoard); initializeGameBoard(*gameBoard); initializeGameBoard(gameBoard); initializeGameBoard(pointer gameBoard);

initializeGameBoard(&gameBoard);

What is unique about the data type union? allows to store different data types in the same memory location allows to store different data types in multiple memory locations allows to store the same data types in different memory locations None of these

allows to store different data types in the same memory location

The data type of a pointer does not need to match the data type of the variable it points to. t/f

false

typedef struct gameboard { char board[ROWS][COLS]; } GameBoard; GameBoard gameBoard; Given the source code above, which of the following code examples is the correct methodology to pass struct GameBoard variable gameBoard to a function as a struct? initializeGameBoard(struct gameBoard); initializeGameBoard(gameBoard); initializeGameBoard(&gameBoard); initializeGameBoard(*gameBoard);

initializeGameBoard(gameBoard);

1 union Data 2 { 3 int i; 4 float f; 5 char str[20]; 6 }; 7 union Data data; 8 data.i = 10; 9 data.f = 220.5; 10 strcpy( data.str, "C Programming"); Given the source code above and the inherent behavior of unions, which union member will have a value stored at the memory address of union Data variable data? f i str All of them

str

What C programming keyword is used to define a structure? union define struct typedef

struct

What C programming keyword is used to define a union? unoin union structure struct

union

What special character is used in C to denote the memory address of a variable? . & -> %

&

What notation is used to dereference a pointer? -> . * &

*

What special character is used when declaring a variable that is a pointer? . -> & *

*

1 typedef struct human 2 { 3 char name[20]; 4 GameBoard gameBoard; 5 Ship ships[NUM_SHIPS]; 6 } Player; 7 Player playerOne; 8 initializePlayer(&playerOne, PLAYERONE); 9 void initializeBoard(Player * player) 10 { 11 player?gameBoard; 12 } Given the source code above, referencing the ? at line 11, which of the following is the correct punctuation or notation to access member gameBoard in parameter player? & -> . *

->

1 typedef struct location 2 { 3 int row; 4 int column; 5 } Location; 6 Location loc; 7 loc?row = 5; 8 loc?column = 5; Given the source code above, referencing the ?'s on line 7 and 8, what is the correct notation to access row and column of struct Location variable loc? -> * . &

.

When accessing union members, what punctuation or notation is used? * . -> &

.

union Data{int i;float f;char str[20];}; Given the inherent behavior of unions and the source code union definition above, how much memory will be allocated for a variable of data type union Data? 24 bytes 4 bytes 20 bytes 28 bytes

20 bytes

How many union members can contain a value at a given time? None All One Half

One

1 typedef struct human 2 { 3 char name[20]; 4 GameBoard gameBoard; 5 Ship ships[NUM_SHIPS]; 6 } Player; 7 Player playerOne; 8 initializePlayer(&playerOne, PLAYERONE); Given the source code above, line 8 is which type of an example regarding pointers? Returning a pointer from a function Declaring a pointer None of these are valid Passing a pointer to a function

Passing a pointer to a function

Which of the following best defines a pointer in C? an enum whose value is the address of another variable a struct whose value is the address of another variable a constant whose value is the address of another variable a variable whose value is the address of another variable

a variable whose value is the address of another variable

typedef struct location{int row;int column;} Location; Given the source code above, what are the variables row and column called in a struct? members arguments constants variables

members


संबंधित स्टडी सेट्स

Leadership exam 2 part 2 (ch. 13 rest, 14,16,17)

View Set

313 Test, Multiple choice questions

View Set

World History 1 Ch 24. Medieval Civilization & Christianity L 1-10

View Set

Ch 24 Structure and a function of Kidneys

View Set

ELECTRICITY AND ELECTRONICS TRAINING SERIES. MODULE 7-SOLID-STATE DEVICES AND POWER SUPPLIES

View Set