COP 3223- Exam 3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

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?

20 bytes

How many union members can contain a value at a given time?

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?

Passing a pointer ot a function

Which of the following best defines a pointer in C?

a variable whose value is the address of another variable

Regarding standard files in the C programming language, which of the following is used for standard error?

stderr

Regarding standard files in the C programming language, which of the following is used for standard input?

stdin

Regarding standard files in the C programming language, which of the following is used for standard output?

stdout

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?

str

What C programming keyword is used to define a structure?

struct

What C programming keyword is used to define a union?

union

How many characters does function putchar() output at a time?

one

What does function scanf() require as a first argument to receive data from stdin?

"char *format"

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?

.

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

False

What is unique about the data type union?

allows to store different data types in the same memory location

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);

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(gameBoard);

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

How many characters does function getchar() read?

one


Set pelajaran terkait

Ancient Civilizations TCI Units 3-6 Terms Template - Unit 3 Ancient India

View Set

Muscles 1-10 (occipitalis-orbicularis oris)

View Set

Chapter 39: Nursing Management: Patients With Rheumatic Disorders

View Set