Incorrect
Marks for this submission: 0/1.
Question 28
Marks: 1
Write a single statement that performs the specified task. Assume that floating-point variables number1 and number2 have been declared and that number1 has been initialized to 7.3. Assume that variable ptr is of type char *. Assume that arrays s1 and s2 are each 100-element char arrays that are initialized with string literals. Assign to ptr the location of the first token in s2. The tokens delimiters are commas (,).
Choose one answer.
|
|
a. ptr = str_tok( s2, ","); |
|
|
|
b. ptr = strtok( s2, ",");
|
|
|
|
c. ptr = tokstr ( s2, ","); |
|
Correct
Marks for this submission: 1/1.
Question 29
Marks: 1
Pointers of different types can never be assigned to one another without a cast operation
Answer:
True
![]()
False
![]()
Correct
Marks for this submission: 1/1.
Question 30
Marks: 1
Which of the following correctly declares an array?
Choose one answer.
|
|
a. int array[10];
|
|
|
|
b. anarray{10}; |
|
|
|
c. int anarray[10]; |
|
|
|
d. array anarray[10]; |
|
|
|
e. int anarray; |
|
Incorrect
Marks for this submission: 0/1.
Question 31
Marks: 1
Why can typecasting be dangerous?
Choose one answer.
|
|
a. You might permanently change the value of the variable. |
|
|
|
b. There are no dangers.
|
|
|
|
c. You might temporarily lose part of the data - such as truncating a float when typecasting to an int. |
|
|
|
d. Some conversions are not defined, such as char to int. |
|
|
|
e. When you cast int to double a floating part can be missed. |
|
Incorrect
Marks for this submission: 0/1.
Question 32
Marks: 1
An expression containing the || operator is true if either or both of its operands are true
Answer:
True
![]()
False
![]()
Correct
Marks for this submission: 1/1.
Question 33
Marks: 1
Write the function header for a function called evaluate that returns an integer and that takes as parameters integer x and a pointer to function poly. Function poly takes an integer parameter and returns an integer.
Choose one answer.
|
|
a. int evaluate( int x, int (*poly)( int ))
|
|
|
|
b. int evaluate( int , int (*)( int )) |
|
|
|
c. int evaluate( int x, int (*poly)) |
|
|
|
d. int evaluate( int x, int (poly)( int )) |
|
Correct
Marks for this submission: 1/1.
Question 34
Marks: 1
Find the error in the following program segment. Assume the following declarations and statements: int *zPtr; // zPtr will reference array z int *aPtr = 0; void *sPtr = 0; int number; int z[ 5 ] = { 1, 2, 3, 4, 5 }; // assign array element 2 (the value 3) to number number = *zPtr[ 2 ];
Choose one answer.
|
|
a. number = &zPtr[ 2 ]; |
|
|
|
b. number = *zPtr( 2 ); |
|
|
|
c. number = zPtr[ 2 ];
|
|
Correct
Marks for this submission: 1/1.
Question 35
Marks: 1
Which of the following statements is true about the program? I. The program compiles without mistakes. II. The program produces beep when executed. III. There are comments in the program.
#include <iostream> using namespace std; int main() { cout << "hello, iitu!" << endl; return 0; }
Choose one answer.
|
|
a. I only |
|
|
|
b. I and III only
|
|
|
|
c. None |
|
|
|
d. I and II only |
|
|
|
e. III only |
|

























