Câu hỏi trắc nghiệm ngôn ngữ lập trình C (tiếp theo)
Code:
struct node *nPtr, *sPtr; /* pointers for a linked list. */
for (nPtr=sPtr; nPtr; nPtr=nPtr->next)
{
free(nPtr);
}
The sample code above releases memory from a linked list. Which of the choices below accurately describes how it will work?
Choice 1
It will work correctly since the for loop covers the entire list.
Choice 2
It may fail since each node "nPtr" is freed before its next address can be accessed.
Choice 3
In the for loop, the assignment "nPtr=nPtr->next" should be changed to "nPtr=nPtr.next".
Choice 4
This is invalid syntax for freeing memory.
Choice 5
The loop will never end.
Q21:
What function will read a specified number of elements from a file?
Choice 1
fileread()
Choice 2
getline()
Choice 3
readfile()
Choice 4
fread()
Choice 5
gets()
Q22:
"My salary was increased by 15%!"
Select the statement which will EXACTLY reproduce the line of text above.
Choice 1
printf("\"My salary was increased by 15/%\!\"\n");
Choice 2
printf("My salary was increased by 15%!\n");
Choice 3
printf("My salary was increased by 15'%'!\n");
Choice 4
printf("\"My salary was increased by 15%%!\"\n");
Choice 5
printf("\"My salary was increased by 15'%'!\"\n");
Q23:
What is a difference between a declaration and a definition of a variable?
Choice 1
Both can occur multiple times, but a declaration must occur first.
Choice 2
There is no difference between them.
Choice 3
A definition occurs once, but a declaration may occur many times.
Choice 4
A declaration occurs once, but a definition may occur many times.
Choice 5
Both can occur multiple times, but a definition must occur first.
Q24:
int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
What value does testarray[2][1][0] in the sample code above contain?
Choice 1
3
Choice 2
5
Choice 3
7
Choice 4
9
Choice 5
11
Q25:
Code: int a=10,b;b=a++ + ++a;
printf("%d,%d,%d,%d",b,a++,a,++a);
what will be the output when following code is executed
Choice 1
12,10,11,13
Choice 2
22,10,11,13
Choice 3
22,11,11,11
Choice 4
12,11,11,11
Choice 5
22,13,13,13
NGUYỄN THỊ BẢO TRANG
» Tin mới nhất:
» Các tin khác: