Test questions for my test today. Please help me ASAP and I have to pass it i have no choice.
a.
13. Comments in Care
Lines starting with “*”
b. Lines starting with “$”
c. A block starting with “**” and ending with “**”
d. none of the above
14. Which of the following is a valid char type variable initialization
char c = ‘1’;
a.
b.
char c;
c.
char c = 22;
none of the above
15. It is bad programming practice to make variable names as short as is possible
true
b. false
a.
a.
16. A conversion/format specification is used to
Read or write formatted data to or from stream
b. Enforce strict type checking during compilation
c. Allow for mixed type variables in language translation
d. More easily allow debugging of complex programs
17. The parenthesis “O” provide higher precedence for the expressions they enclose
true
b. false
a.
18. An expression always evaluates to a single value
true
b. false
a.
19.
A side effect is
a. an action that results from the evaluation of an expression
b. an undesirable result invalid code
c. an operation performed within an included library function
d. a syntactical/compile time error
20. What is the value of x after the following code is evaluated
int x = 0;
x = 5%2;
2.5
b. 2
a.
c.
1
d.
0
21.
a.
Which of the following is a valid scanf statement for reading 3 ints a, b, and c;
scanf(“%d” “%d” “%d”, a, b, c);
b. scanf(“%d %d %d” &a,&b, &c);
c. scanf(“%d %d %d”, a, b, c);
d. None of the above
a.
22. Scope refers to
The possible number of iterations in a looping structures like “while” and “for”
b. The breath of applications a given high level language can be used for
The portion of a program where a given variable or constant is valid
d. The range of the number set for a given type, such as int or float
C.
23. Top-down design consists of breaking a program into simple, understandable parts
a.
b.
true
false
24. AC function must be both declared and defined
a. true
b. false
25. A C function must either have parameters or return a value
a.
true
b. false
26. The function header consists of the return type, the function name, and the formal parameter list, in that order
a. true
b. false
27. In downward communication, the calling function receives data from the called function
a.
b.
true
false
28. The following code exchanges the values in the x and y variables
temp = x;
x=y;
y=temp;
a. true
b. false
29. The default label is optional in the switch statement
a.
b.
true
false
30. In a counter-controlled loop, we always add to a counter to determine when to terminate the loop
a. true
b. false
31. Which of the following statements about functions is false?
a. Functions must be both declared and defined
b. Function declaration needs to be done before it is called
c.
Function declaration contains the code needed to complete the task
d. The function declaration contains the name of the program, its return type, and a formal parameter list
The function declaration is generally placed in the global portion of the program
e.
a.
32. A variable that is defined inside a function and used without having any role in the communication between functic
global variable
b. local variable
c. defined variable
d.
constant variable
a.
33. Which of the following consists only of a function header
function header
b. function declaration
formal parameter list
d. actual parameter list
C.
a.
34. Which of the following statements about a function call is false
A function call is a postfix expression
b. The operand in a function call is the function name
The parameter list contains the formal parameters
The parameter list must match the function headers parameters in type and order
un of the call of a void function cannot be assigned
c.
d.
1
When the calling function sends data to the called function and the called function sends data to the calling function what you
35.
communications is it called
a. downward
upward
c. bi-directional
d. bi-lateral
36.
a.
What type of communication is provided by the return statement
downward
b. upward
bi-directional
d. lateral
c.
a.
37. Which of the following statements about structure charts is false
Structure charts are a program design tool
b. Structure charts are used in design reviews to validate the design
Structure charts are read top-down, left-right
Structure charts contain code for key functions
Structure charts may optionally contain data flows
c.
d.
e.
38. Which of the following about conditional expressions is true
a. conditional expressions are illegal in C
b.
conditional expressions use compile time redirect ASCII codes
conditional expressions are neither conditional or expressions
d. conditional expressions can always evaluate to a single value
c.
a.
39. Which of the following is not a logical operator
if
b. not
c. and
d.
or
40. A return statement can be used in functions but not in the main program
a. true
b. false
41. Which of the following statements about the logical or operator is false
a. Because it is a binary operator, there are four distinct possible combinations of values
b. The or operator is false only when both operands are false
c. The or operator selects between two values
d. The expression type for an or expression is Boolean
42. Terminating main with exit has the same effect as terminating it with return
a. true
b. fasle
a.
43. Which of the following would be the best example of an event-controlled loop
loop exit condition based on user input
b. loop control variable incremented on each iteration
loop control variable declared as global constant value
d.
an infinite loop
c.
a.
44. Which of the following would be the best example of a counter-controlled loop
loop exit condition based on user input
b. loop control variable incremented on each iteration
loop control variable declared as global constant value
d. an infinite loop
c.
a.
45. Which of the following statements about the do…while loop is true
conditional statement is at the top of the loop structure
b. loop body is guaranteed to execute at least once
c. syntax is exactly same as for loop but upside down
hest structure to use for counter controlled looping
46.
Which of the following is not a good rule for programming style
With a series of selection statements, code the most probable first
a.
b.
c.
d.
One statement with multiple negative expressions is preferred over a series of multiple statements
For human engineering reasons, code the most probable conditions first
Code positive statements whenever possible
Avoid compound negative statements
e.
a.
47. Which of the following statements about the for loop is false
It is used when a loop is to be executed a known number of times
b.
Initialization is usually done in the first expression within the statement
The limit is the second expression in the statement
d.
The update may be done as the last expression in the statement or within the action body
e.
It is an event-controlled loop
c.
break
48. The statement that transfers execution to the test expression in while or do…while statements and the update in a for statement
a.
b.
continue
c. goto
d.
comma
e. recursion
49. Pointers
a.
b.
are an efficient method to access data
provide efficient techniques for manipulating data in arrays
can be used in functions as pass-by-reference parameters
All of the above
c.
d.
50. The unary operator * extracts the address of a variable
a. true
b. false
51. A pointer type is a derived type
a.
true
b.
false
52. A pointer variable stores the address of a variable
true
b. false
a.
53. A pointer constant for a given variable, which is drawn from the set of addresses from computer memory, ca
programmer
a.
true
b.
false
54. The unary operator & extracts the value of a variable
true
a.
b.
false
inta;
int p;
int** :
a = 58;
p=&a;
q=&p;
printf(“%3d”, a);
printf(“%3d”, *p);
printf(“%3d”, **q);
a.
b.
58 37552 null
37552 37552 null
58 null 58
none of the above
C.
d.
a.
56. The address of a variable is
the first byte of the variable times the length of the variable type
b. an unknowable number maintained by the operating system
C. always located on a even byte offset value
d. the first byte occupied by the variable
a.
57. A pointer variable contains
the value of the variable it is pointing to
b. the address of the variable it is pointing to
c. a type definition of the target data element
d. the dereference operator
58. The address and indirection operators are inverse operators
true
b. false
a.
59. Which of the following is a valid pointer declaration
int* a;
b. int &a;
a.
c.
int a;
d.
int %a;
60. An uninitialized pointer variable is a pointer to an unknown location
a.
true
b.
false
61. A pointer variable may be initialized to NULL which indicates it is intentionally not pointing to anything
true
b.
false
a.
62.
When exchanging the values of two variables in a function using pointers it is necessary to use a temporary variable
a.
true
b.
false
63.
Multiple pointer variables may point to the same memory location
a.
true
b.
false
different location