Accounting
Anthropology
Archaeology
Art History
Banking
Biology & Life Science
Business
Business Communication
Business Development
Business Ethics
Business Law
Chemistry
Communication
Computer Science
Counseling
Criminal Law
Curriculum & Instruction
Design
Earth Science
Economic
Education
Engineering
Finance
History & Theory
Humanities
Human Resource
International Business
Investments & Securities
Journalism
Law
Management
Marketing
Medicine
Medicine & Health Science
Nursing
Philosophy
Physic
Psychology
Real Estate
Science
Social Science
Sociology
Special Education
Speech
Visual Arts
Computer Science
Q:
In the statement
fseek (fPtr, (account " 1) * sizeof(struct clientData), SEEK_SET);
why are we adjusting account by "1?
a) Because the account numbers start at 0 and the file starts at position 0.
b) Because the account numbers start at 0 and the file starts at position 1.
c) Because the account numbers start at 1 and the file starts at position 0.
d) Because the account numbers start at 1 and the file starts at position 1.
Q:
Which statement is true?
a) fread always reads a record at a time from a file into memory.
b) fread reads a specified number of bytes from a file into memory.
c) Every fread call must include an argument with sizeof.
d) fread reads bytes from a position in the file specified as one of fread's arguments.
Q:
Which of the following is a function that reads a specified number of bytes from a file into memory?
(a) fseek
(b) fwrite
(c) fread
(d) fopen
Q:
The symbolic constant __________ indicates that the file position pointer is to be positioned relative to the beginning of the file by the amount of the offset.
a) SEEK_SET
b) SEEK_BEGIN
c) SEEK_START
d) SEEK_CUR
Q:
Which statement is true?
a) fseek searches for a record by its record key.
b) fseek sets the file position pointer to a specific byte location in the file.
c) fseek moves the read-write head on the disk to the location on disk that corresponds to a specific location in a file.
d) fseek must immediately follow each call to fread or fwrite.
Q:
Which of the following is an argument of the fseek function that can have the values SEEK_SET,
SEEK_CUR or SEEK_END?
(a) stream
(b) offset
(c) whence
(d) none of these
Q:
sizeof
a) is a compile-time function
b) is a compile-time unary operator
c) is a run-time unary operator
d) is a run-time function
Q:
Which statement is true?
a) Random access file-processing programs typically read and write one field at a time.
b) Random access file-processing programs typically read and write one struct at a time.
c) The sizeof operator is a run-time unary operator that returns the size in bytes of its operand.
d) The expression sizeof(int) always returns 4.
Q:
fread and fwrite
a) can not read and write arrays of data
b) process all their data in human readable format
c) process all their data in the same format used by fscanf and fprintf, respectively
d) process all their data in "raw data" format
Q:
Function fwrite __________.
a) is equivalent to function fprintf
b) transfers a specified number of bytes beginning at a specified location in memory to a location in a file indicated by the file position pointer
c) transfers a specified number of bytes beginning at a specified location in memory to a location in a file indicated by one of its arguments
d) is equivalent to function fprintf, except that fwrite can only write to standard streams
Q:
What is the significance of the 1 in the following statement?
fwrite(&number, sizeof(int), 1, fPtr);
(a) It specifies that the file is to be opened for updating.
(b) It specifies the number of elements in the array that should be written to disk.
(c) It specifies the byte size of the element being written to disk
(d) none of these
Q:
Which statement is false?
a) Randomly accessed files are popular in transaction processing systems.
b) Data stored previously in a randomly accessed file can be updated or deleted without rewriting the entire file.
c) Records of a randomly accessed file are normally fixed in length (i.e., all the record in the file are the same length).
d) A record of a randomly accessed file is normally located by searching the portion of that file which precedes that record.
Q:
Which of the following is false?
(a) Data can be inserted in a randomly accessed file without destroying other data in the file.
(b) There is more than one way to implement randomly accessed files.
(c) Randomly accessed files cannot be accessed directly without searching through other records.
(d) Data stored previously can be updated or deleted without rewriting the entire file.
Q:
Individual records of a randomly accessed file are normally ________.
(a) fixed in length
(b) not fixed in length
(c) sorted by record key
(d) read using the fopen function
Q:
Which statement is true?
a) The file position pointer is a pointer to a FILE structure.
b) The file position pointer is a pointer to an FCB.
c) The file position pointer is not really a pointer.
d) The file position pointer specifies the file reset.
Q:
The rewind statement causes __________.
a) the disk to stop spinning, then spin in reverse until it repositions to the beginning of the file.
b) the contents of the file to be erased.
c) a program's file position pointer to be repositioned to the beginning of the file (i.e., byte 0).
d) a file to be closed and then re-opened.
Q:
Function fscanf is equivalent to function scanf, except that fscanf
a) can have only a single argument.
b) can read only from standard streams.
c) can read only from open streams.
d) receives as an argument a file pointer for the file from which the data is read.
Q:
Which of the following is a function that causes a program's file position pointer to be repositioned to the beginning of the file?
(a) rescan
(b) rewind
(c) return
(d) none of these
Q:
Function fscanf takes an argument of type ________.
(a) FILE pointer
(b) cfPtr
(c) char
(d) int
Q:
Which statement is true?
a) fopen returns a FILE structure.
b) fopen returns a pointer to a FILE structure.
c) fopen returns a file control block (FCB).
d) fopen returns a pointer to a file control block (FCB).
Q:
If an error occurs while opening a file in any mode, fopen __________.
a) causes program termination
b) returns NULL
c) issues the message "can"t open file"
d) diagnoses the error, waits five minutes and retries
Q:
Which statement is false?
a) Each file used in a program must have a unique name and will have a different file pointer returned by fopen.
b) All subsequent file processing functions after the file is opened must refer to the file with the appropriate file control block.
c) To create a file use file open mode "w".
d) To add records to an existing file, pen the file for appending ("a").
Q:
If a file is not closed explicitly by a program __________.
a) the operating system normally will close the file when program execution terminates
b) the file will be left open when the program terminates, creating a possible security breach
c) the operating system will query the user to determine if he or she wishes to close the file when the program terminates
d) the operating system will not allow the owner of that program to run any other programs
Q:
Which statement is true?
a) Function fprintf is equivalent to printf.
b) Function fprintf is equivalent to printf except that fprintf also receives as an argument a file pointer for the file to which the data will be written.
c) Function fprintf is equivalent to printf except that fprintf also receives as an argument a file control block for the file to which the data will be written.
d) Function fprintf is equivalent to printf except that fprintf also disables the file end-of-file indicator.
Q:
Function feof __________.
a) forces an end-of-file condition
b) determines whether the end-of-file indicator is set for a file
c) sets the end-of-file indicator for a file
d) flushes the contents of the file from the current position to the end
Q:
If an existing file is opened for writing __________.
a) the contents of the file are preserved
b) the contents of the file are discarded and an error code is returned
c) the contents of the file are discarded without warning
d) the newly written data is appended to the end of the file
Q:
Before a file can be accessed it must first be
a) copied
b) read
c) written
d) opened
Q:
Which of the following statements is false?
a) The programmer must know the specifics of the FILE structure to use files.
b) The FILE structure for a file leads indirectly to the operating system's file control block (FCB) for a file.
c) If a file does not exist and is opened for writing fopen creates the file.
d) A C program administers each file with a separate FILE structure.
Q:
Which statement is false?
a) The programmer must provide any file structure to meet the requirements of each particular application.
b) A programmer can impose a record structure on a file.
c) Records must be written to a C file in order by record key.
d) The notion of a record of a file does not exist in C.
Q:
Which statement is true?
a) C imposes no structure on a file.
b) C imposes record structure on a file.
c) C imposes sequential access on a file.
d) C imposes hierarchical access on a file.
Q:
If an error occurs while opening a file in any mode, function fopen returns ________.
(a) true
(b) NULL
(c) false
(d) -1
Q:
Which mode would you use if you wanted to open a file for both reading and writing?
(a) r+
(b) w+
(c) a+
(d) all of these
Q:
Function fputs writes a __________ to a file.
a) character
b) stream
c) line
d) standard output
Q:
Function __________ reads one character from a file.
a) fgetcharacter
b) fgetc
c) fgetchar
d) fgetbyte
Q:
The standard __________ stream enables a program to read data from the keyboard.
a) read
b) keyboard
c) dialog
d) input
Q:
__________ provide communication channels between files and programs.
a) Streams
b) Records
c) File descriptors
d) File control blocks (FCBs)
Q:
Which of the following is not automatically opened when a C program begins?
a) standard error
b) standard output
c) standard dialog
d) standard input
Q:
C views each file simply as a sequential stream of __________.
a) bits
b) bytes
c) fields
d) records
Q:
Which of the following is not part of the FILE structure specified in <stdio.h>?
(a) file descriptor
(b) open file table
(c) read/write methods
(d) file control block
Q:
Which of the following is not a stream associated with C files?
(a) stdin
(b) stdout
(c) stdchar
(d) stderr
Q:
Which of the following is false?
a) Storage of data in memory variables is temporary; all such data is lost when a program terminates.
b) Computers store files on primary storage devices, typically disk storage devices.
c) Files are used for permanent retention of data (typically large amounts of data).
d) Storage of data in memory arrays is temporary; all such data is lost when a program terminates.
Q:
________ are used for permanent retention of large amounts of data.
(a) Structures
(b) Arrays
(c) Records
(d) Files
Q:
Which of the following is true?
a) Any bit "ANDed" with 0 yields 0.
b) Any bit "ANDed" with 1 yields 1.
c) Any bit "ANDed" with 0 yields 1.
d) Any bit "ANDed" with 1 yields 0.
Q:
In bitwise manipulations, a mask is typically __________.
a) A floating point value with specific bits set to 1.
b) An integer value with specific bits set to 1.
c) An integer value with specific bits set to 0.
d) A floating point value with specific bits set to 0.
Q:
Which statement is true of the >> operator?
a) It is called the left shift operator.
b) It is called the bitwise left shift operator.
c) It shifts the bits of the first operand right by the number of bits specified by the second operand.
d) It fills from the left portably across platforms.
Q:
Which statement is true of the << operator?
a) It's called the right shift operator.
b) It's called the bitwise right shift operator.
c) It shifts the bits of the second operand left by the number of bits specified by the first operand.
d) It fills from the right with 0 bits.
Q:
Which operator sets the bits in the result to 1 if at exactly one of the corresponding bits in the two operands is 1?
a) bitwise AND
b) bitwise inclusive OR
c) bitwise exclusive OR
d) bitwise complement
Q:
Which operator sets the bits in the result to 1 if at least one of the corresponding bits in the two operands is 1?
a) bitwise AND
b) bitwise inclusive OR
c) bitwise exclusive OR
d) bitwise complement
Q:
Which operator sets the bits in the result to 1 only when the corresponding bits in the two operands are both 1?
a) bitwise AND
b) bitwise inclusive OR
c) bitwise exclusive OR
d) bitwise complement
Q:
The bitwise operators can be used to manipulate the bits of variables of type __________.
a) float
b) double
c) long
d) long double
Q:
For any eight-bit x, which of the following does not result in zero?
(a) x &= (~x)
(b) x ^= x
(c) x <<= 8
(d) x |= x
Q:
Let x be an int on a machine with four-byte ints. What effect does
x<<=1;
x>>=1;
have?
(a) There is no effect.
(b) The leftmost bit of x is set to zero.
(c) The rightmost bit of x is set to zero.
(d) Both (b) and (c).
Q:
Evaluate (00001000 & 11000101) ^ (11110000)
(a) 00111101
(b) 11000000
(c) 00111101
(d) 11110000
Q:
Let Bit1 = Bit2 = 1. Which of the following does not have the same result as the others?
(a) Bit1 & Bit2
(b) Bit1 | Bit2
(c) Bit1^Bit2
(d) ~(~Bit2)
Q:
Which of the following is not a bitwise operator?
(a) ^
(b) &
(c) ~
(d) *
Q:
The most basic unit of data on a computer is the
(a) bit.
(b) byte.
(c) file.
(d) int.
Q:
Which statement is true?
a) The members of a union can be of any type.
b) The members of a union must all be of the same type.
c) A union may not be assigned to another union of the same type.
d) Unions may be compared to other unions of the same type.
Q:
Which of the following is true?
a) A union typically makes less efficient use of memory than a struct.
b) A union is another name for a struct.
c) A union is a derived data type whose members share the same storage space.
d) Unions are always portable between different computers with different compilers.
Q:
Which of the following is not an operation that can be performed on a union?
(a) comparing using the != operator
(b) taking the address (&) of a union
(c) accessing union members using the structure member operator
(d) assigning a union to another union of the same type
Q:
Which of the following is true?
(a) Unions may be compared using the == operator.
(b) The address operator (&) cannot be used to take the address of a union.
(c) Unions may only contain two data types.
(d) Only one union member, and thus one data type, can be referenced at a time
Q:
Which of the following is always a syntax error?
a) Not using srand in every program that uses rand.
b) Not using rand in every program that uses srand.
c) Not using const when passing an array.
d) Forgetting to include the array subscript when referring to individual structures in an array of structures.
Q:
What does the statement typedef struct card Card; do?
a) Defines card as a synonym for Card.
b) Defines Card as a synonym for card.
c) Defines Card as a synonym for struct card.
d) Defines Card as a synonym for typedef struct card.
Q:
Which statement is true?
a) Often, typedef is used to create synonyms for the basic data types.
b) Keyword typedef is used to create antonyms (or opposites) for the basic data types.
c) Names for structure types are typically defined with typedef to create longer type names.
d) The first letter of each typedef name must be capitalized.
Q:
Creating a new name with typedef __________.
a) creates a new type
b) creates a new type name
c) creates a new variable name
d) creates a new variable
Q:
Advantages of typedef do not include
(a) making programs more portable by allowing data types to be easily changed to meet system specifications.
(b) making type names shorter.
(c) making programs more readable.
(d) increasing the efficiency of accessing struct member variables.
Q:
typedef is used to
(a) create a name that is an alias for a previously defined data type.
(b) create new data types.
(c) cast one struct to another type.
(d) initialize struct members.
Q:
. Which of the following is false?
a) To pass a structure by reference, pass the address of the structure variable.
b) A way to pass an array by value, is to create a structure with the array as a member then pass the name of the structure.
c) To pass a structure by reference, pass the name of the structure variable.
d) Passing large structures by reference is more efficient than passing large structures by value.
Q:
. An array of structures is automatically passed __________.
a) by value
b) by reference
c) by aggregate
d) by enumeration
Q:
. A structure of arrays is automatically passed __________.
a) by value
b) by reference
c) by aggregate
d) by masking
Q:
Arrays of structures ________.
(a) are automatically passed by reference
(b) are automatically passed by value
(c) cannot be passed by reference
(d) None of the above.
Q:
Structures may be passed to functions by ________.
(a) passing individual structure members
(b) passing an entire structure
(c) passing a pointer to the structure
(d) all of these
Q:
. Which of the following is false?
a) Structure member names throughout a program must be unique.
b) Attempting to refer to a member of a structure by using only the member's name is an error.
c) Inserting a space between the - and > of operator -> is an error.
d) The dot operator (.) is the structure member operator.
Q:
. The expression aptr->suit is equivalent to __________.
a) aptr.suit
b) *aptr.suit
c) (*aptr).suit
d) *aptr.(suit)
Q:
The ________ accesses a structure member via the structure variable name.
(a) structure member operator
(b) structure pointer operator
(c) structure arrow operator
(d) none of these
Q:
Arrays are
(a) always passed call-by-reference.
(b) passed call-by-reference unless inside a structure.
(c) always passed call-by-value.
(d) passed call-by-value unless inside a structure.
Q:
. Structures can be initialized in __________ statements.
a) assignment
b) null
c) scope
d) empty
Q:
. If there are fewer __________ in the list than members in the structure, the remaining members are automatically initialized to 0 or NULL.
a) quantifiers
b) initializers
c) numerators
d) variables
Q:
What does the following statement do?
struct card a = {"Three", "Hearts"};
(a) It creates a variable card of type struct with two members specified in the list.
(b) It creates two variables named Three and Hearts of type struct card a.
(c) It creates a variable a to be of type struct card and initializes it to the values in the list.
(d) It creates two variables named Three and Hearts of type struct card.
Q:
Structure variables may not be initialized by
(a) setting user-defined default variable values in the struct definition.
(b) assigning values to individual data members.
(c) array-like member initializer lists.
(d) assignment statements.
Q:
. Which of the following is not a valid operation on a structure?
a) Assigning structure variables to structure variables of the same type.
b) Taking the address of a structure variable.
c) Using the sizeof operator to determine the size of a structure variable.
d) Comparing structures of the same type with relational operators.