COP3223 Exam 3

Réussis tes devoirs et examens dès maintenant avec 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 to a function

C programming keyword typedef allows software developers to give an existing data type a new name.

True

typedef interpretation is performed by the compiler.

True

typedef is limited to giving symbolic names to types only.

True

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

Given the source code below, how should a developer declare a variable of struct BookTwo? Select all that apply. typedef struct BookTwo { char title[50]; char author[50]; char subject[100]; int book_id; } BOOK;

struct BookTwo aBook; BOOK aBook;

What C programming keyword is used to define a union?

union

Given the source code below, match the term to the components of the struct definition. struct { unsigned int age : 3; } Age;

unsigned int-data type of bit field age-name of the bit field 3-size of the bit field in bits Age-variable of the bit field struct

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?

.

Given the code example below, what is the maximum value that can be stored in bit field age? struct { unsigned int age : 4; } Age;

15

Given the source code below, how much memory is allocated to bit fields widthValidated and heightValidated each? struct { unsigned int widthValidated : 1; unsigned int heightValidated : 1; } status2;

2 bits

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

What is the term associated with variables defined with a predefined width?

bit fields

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


Ensembles d'études connexes

NUR 300: Chapter 36: Spiritual Health

View Set

Homeowners Insurance: Section I of the HO-3

View Set

Chapter 9: Raising Kids in a diverse society

View Set

Pharmacology and the nursing process: chapters 1-3

View Set

Trauma/SCI/TBI/ICP NCLEX Questions

View Set