Intro To C Exam 3

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What notation is used to dereference a pointer?

*

What special character is used when declaring a variable that is a pointer?

*

_____ reads the next available character from the screen and returns it as an integer.

getchar()

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

A pointer that is assigned NULL is called a _____ pointer.

null

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

one

To hold the null character at the end of the array, the size of the character array containing the string is _____ more than the number of characters in the word

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

A _____ is a variable whose value is the address of another variable, i.e., direct address of the memory location.

pointer

_____ writes the output to the standard output stream stdout and produces the output according to the format provided.

printf()

_____ puts the passed character on the screen and returns the same character.

putchar()

_____ writes the string 's' and 'a' trailing newline to stdout

puts()

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 output?

stdout

_____ is another user defined data type available in C that allows to combine data items of different kinds.

structure

_____ are used to represent a record.

structures

_____ is an integer type that determines how a bit-field's value is interpreted. The type may be int, signed int, or unsigned int.

type

_____ is the pointer's base type; it must be a valid C data type

type

The general form of a pointer variable declaration

type *var-name;

The C programming language provides a keyword called _____, which you can use to give a type a new name.

typedef

You can use _____ to give a name to your user defined data types as well

typedef

_____ interpretation is performed by the compiler

typedef

_____ is limited to giving symbolic names to types only

typedef

_____ is the name of the pointer variable.

var-name

To access the members of a structure using a pointer to that structure, you must use the _____ operator

What is unique about the data type union?

allows to store different data types in the same memory location

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

"char *format"

_____ can be used to define alias for values as well, q., you can define 1 as ONE etc

#define

_____ is a C-directive which is also used to define the aliases for various data types

#define

_____ statements are processed by the pre-processor.

#define

To find the address of a structure variable, place the _____; operator before the structure's name

&

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

C programming treats all the _____ as files

devices

Which of the following best defines a pointer in C?

a variable whose value is the address of another variable

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

false

_____ reads a line from stdin into the buffer pointed to by s until either a terminating newline or EOF (End of File).

gets()

_____ reads the input from the standard input stream stdin and scans that input according to the format provided.

scanf()

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

stdin

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

Concatenates string s2 onto the end of string s1

strcat(s1, s2)

Returns a pointer to the first occurrence of character ch in string s1.

strchr(s1, ch)

Returns 0 if s1 and s2 are the same; less than 0 if s1 < s2; greater than 0 if s1 > s2.

strcmp(s1, s2)

Copies string s2 into string s1

strcpy(s1, s2)

_____ are actually one-dimensional array of characters terminated by a null character '\0'.

strings

Returns the length of string s1

strlen(s1)

Returns a pointer to the first occurrence of string s2 in string s1.

strstr(s1, s2)

Split a string into tokens

strtok(s1, delim)

The _____ statement defines a new data type, with more than one member.

struct

What C programming keyword is used to define a structure?

struct

How do you pass pointers to structures?

struct Books *struct_pointer;

The _____ is optional and each member definition is a normal variable definition, such as int i; or float f; or any other valid variable definition.

structure tag

What C programming keyword is used to define a union?

union

The _____ is optional and each member definition is a normal variable definition, such as int i; or float f; or any other valid variable definition.

union tag

After this type definition, the identifier BYTE can be used as an abbreviation for the type _____

unsigned char

_____ is the number of bits in the bit-field. The width must be less than or equal to the bit width of the specified type

width

What special character is used in C to denote the memory address of a variable?

&

How many characters does function getchar() read?

one

How many characters does function putchar() output at a 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); 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 variables defined with a predefined width are called _____.

bit fields

_____ allow the packing of data in a structure.

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 struct?

initializeGameBoard(gameBoard);

The memory occupied by a union will be large enough to hold the _____ member of the union.

largest

If multiple values of a union are set, the _____ value assigned holds.

last

The _____ is coded as a period between the structure variable name and the structure member that we wish to access.

member access operator

-To access any member of a union, we use _____ the .

member access operator (.)

To access any member of a structure, we use the _____.

member access operator (.)

_____ is the name of the bit-field

member_name

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

A bit field can hold _____ than a single bit

more


Kaugnay na mga set ng pag-aaral

Intro to Astronomy: Hw Questions First Exam

View Set

Parallel and Perpendicular lines

View Set

Human Resource Management Chapter 8

View Set