1. The operators: & | ^ are: a) AND OR NOT b) AND OR XOR c) AND NOT NAND d) AND
ID: 3621412 • Letter: 1
Question
1. The operators: & | ^ are:
a) AND OR NOT
b) AND OR XOR
c) AND NOT NAND
d) AND NOR XOR
e) none of these
2. Identical programs using only C syntax will tend to run slower when
compiled as C++ rather than C. (T/F).
3. Assuming that spread[] is a one-dimensional
array of type int, which of the following
refers to the value of the third element in the array?
a. *(spread+4) b. spread[2]
c. spread[3] d. spread+2
4. TF Both malloc() and new[] return addresses.
5. C is an Object Oriented Programming (OOP) language. (T/F).
6. The C programming language is contained within
the C++ programming language (T/F).
7. One of the methods NOT normally used to send data from the CALLED function to the CALLING function in C is:
a. global variable
b. pointer to variable in calling function
c. instruction pointer register
d. return value of called function
e. none of the above
8. A benefit of C++ is:
a. reusable code via Inheritance.
b. modularization via Encapsulation.
c. abstraction thru the use of Templates.
d. all of the above.
e. none of these.
9. The constant "C" occupies how many bytes?
a. 4 b. 3 c. 2 d. 1 e. none of the above
10. Many variables of the same Type, having the same Name,
grouped together and referenced via an integer value
constitute:
a. a class.
b. an array.
c. a struct.
d. a pointer.
e. none of these.
11. Define: Pass by Reference:
a. pass a copy of the variable's contents on the stack
b. pass the address of the variable on the stack
c. write a temp file to disk
d. write a temp buffer to working storage
e. none of the above
12. Define: Pass by Value
a. pass a copy of the variable's contents on the stack
b. pass the address of the variable on the stack
c. write a temp file to disk
d. write a temp buffer to working storage
e. none of the above
13. Given:
float f , g ;
.
.
.
the better choice of the two comparisons below would be:
a. if (f >= g)
b. if (f == g)
14. To copy the contents of int b[200] to int a[200], you would:
a. a = b ;
b. memcpy(a, b, sizeof(a)) ;
c. use a correctly written for() loop
d. b or c above
e. a, b, or c above
15. If you want to read in the users name (first, (maybe
a middle) , last) from the keyboard, your usual method would be:
a. cin >>
b. cin.get()
c. cin.getline()
d. each is as good as the others
e. only a and b would work
16. Given:
int a[10][5] ;
to access the second item in the
3rd row, we would use:
a. a[2][3] ; becomes *(*(a + 2) + 3
b. a[3][2] ; becomes *(*(a + 3) + 2)
c. *(*(a+3)+2) ;
d. *(*(a+2)+1) ;
e. none above
17. The #ifdef, #elif, #else, and #endif
constructs are used to:
a. decide what code the compiler includes in the program
b. control program execution at run time
c. pass arguments back to dos during program execution
d. both a and b above
e. all of the above
18. In C standard library I/O, the function
used to disconnect a FILE * pointer from the
disk hardware after writing is:
a. fclose()
b. close()
c. unlink()
d. chmod()
e. none above
19. The ifstream and ofstream objects are both examples of
object creation by inheriting from the fstream object. (T/F).
* ofstream: Stream class to write on files
* ifstream: Stream class to read from files
* fstream: Stream class to both read and write from/to files.
20. sprintf() can translate between decimal, Hexadecimal, and
Octal. (T/F).
21. Object Oriented Programming uses "objects" which may contain:
a. data
b. executable code
c. either data or executable code, not both
d. both a and b plus other class objects
e. none are true
22. When searching a sorted array:
a. linear searching is more efficient
b. binary searching is more efficient
c. efficiency is a function of array type
d. binary is faster only if it is an array of floats
e. none of these are true
23. To do array processing, it is necessary to know
the size an array will be when you are writing the
program. (T/F).
24. To print the address of x given: int x, * pt; pt = &x ; you would
a. printf("%X ", pt) ;
b. printf("%X ", &x) ;
c. printf("%X ", *pt) ;
d. a & b above
e. none of the above
25. An array may never be initialized at compile time
a. true b. false
int a[] = {1, 4, 5, 98} ;
26. Suppose an array has been defined as int arr[3]; , can you use the expression arr++ ?
a. yes b. no
27. To allocate a two-dimensional array, a definition like: int arf[50,50] is used.
a. true b. false
28. When you pass an array as an argument to a function, what is actually passed?
a. the address of the array
b. the values of the elements in the array
c. a duplicate of the array
d. the number of elements in the array
e. none of the above
29. An assignment statement itself has a value, just like a variable. (T/F)
x = y = z = 0 ;
30. In a simple if statement with no else, what happens if the condition is false?
a. the program searches for the last else in the program
b. nothing
c. control "falls through" to the statement following the if construction
d. the body of the if statement is executed
31. The purpose of the " ? : " operator is to:
a. select the highest of the two values
b. select the more equal of two values
c. select one of two values alternately
d. select one of two values depending on a condition
e. none of the above
32. The statements following else in an if-else construction are executed when
a. the conditional expression following if is false
b. the conditional expression following if is true
33. It is possible to print decimal-point-aligned
financial data using cout using the sprintf() function. (T/F).
34. A non-static global variable may be altered
by functions which are declared in any source file
included in the project. (T/F)
35. A static function may only be called by
functions which are defined in the same
source file. (T/F)
36. A static int variable is allocated only
once in the run of the program, and keeps its
value between calls of the function in which
it is defined. (T/F)
37. C variables declared inside a function {}
are visible only to the calling routine. (T/F)
38. Given:
main(int argc, char *argv[], char ** env)
argv[0] is local only to main, and may not be directly
seen or used by any other function. (T/F)
39. static_cast<double>() is most similar to:
a. (double *)
b. (char *)
c. (int)
d. (double)
e. none of these
40. Given: int a = 8 , b = 9 ;
in order to get an accurate quotient, you must do:
a. cout << a / b ;
b. cout << (double) a / b ;
c. cout << (double) (a / b) ;
d. b or c above.
e. they all produce an accurate answer.
Explanation / Answer
1. The operators: & | ^ are
a) AND OR NOT
b) AND OR XOR
c) AND NOT NAND
d) AND NOR XOR
e) none of these
Solution:
Thus the Correct option is (b)
2. Identical programs using only C syntax will tend to run slower when
compiled as C++ rather than C. (T/F).
Solution:
3. Assuming that spread[] is a one-dimensional array of type int, which of the following
refers to the value of the third element in the array?
a. *(spread+4)
b. spread[2]
c. spread[3]
d. spread+2
Solution:
Thus the correct option is (b)
4. TF Both malloc() and new[] return addresses.
Solution
The statement Both malloc() and new[] return addresses is True
5.C is an Object Oriented Programming (OOP) language. (T/F).
Solution
The C is an Object Oriented Programming (OOP) language. (T/F). is False.
6. The C programming language is contained within the C++ programming language (T/F).
Solution
The statememnt The C programming language is contained with in the C++ programming language is True.
7. One of the methods NOT normally used to send data from the CALLED function to the CALLING function in C is:
a. global variable
b. pointer to variable in calling function
c. instruction pointer register
d. return value of called function
e. none of the above
Solution:
Thus correct option is (a)
8. A benefit of C++ is:
a. reusable code via Inheritance.
b. modularization via Encapsulation.
c. abstraction thru the use of Templates.
d. all of the above.
e. none of these.
Solution :
Thus correct option is (c)
9. The constant "C" occupies how many bytes?
a. 4 b. 3 c. 2 d. 1 e. none of the above
Solution:
Thus correct option is (c)
10. Many variables of the same Type, having the same Name,grouped together and referenced via an integer value constitute:
a. a class.
b. an array.
c. a struct.
d. a pointer.
e. none of these.
Solution:
Thus correct option is (b)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.