CNIT 105 Final Exam
Assume the following:
int num;
int * ptr;
Which statement will make the pointer point to variable num?
ptr = num;
ptr -> num;
ptr = &num - answerptr = &num
When should the end of the file be checked?
A. When opening the file.
B. When writing to the file.
C. When reading from the file.
D. When closing the file. - answerC. When reading from the file.
The text file scores.txt contains some integer numbers. It has been opened for reading
using the file pointer ptr.
Which statement will read the first number from the file into the variable score?
Assume: int score;
A. fscanf (ptr, "%d", score);
B. fscanf (ptr, "%d", &score);
C. fscanf ("%d", &score);
D. fscanf (ptr, &score); - answerB. fscanf (ptr, "%d", &score);
To work with a text file, which one of the following declarations is required?
, A. FILE ptr;
B. FILE * ptr;
C. File * ptr;
D. file * ptr; - answerB. FILE * ptr;
What does the function feof() return when the end of the file is reached?
A. it returns true (which is 1)
B. it returns the number of lines in the file.
C. It returns false (which is 0)
D. it returns -1 - answerA. it returns true (which is 1)
Assume the following declaration:
int num;
int * ptr;
Which statement will make the pointer point to variable num?
A. ptr = num;
B. ptr = #
C. ptr -> num;
D. ptr = # - answerD. ptr = #
Assume that the input file data.txt has been opened for reading using the file pointer
fptr.. The file contains several whole numbers:
34
55
90
22
100
16
Which of the following will read the third value into variable number?
Assume: int number;
Assume the following:
int num;
int * ptr;
Which statement will make the pointer point to variable num?
ptr = num;
ptr -> num;
ptr = &num - answerptr = &num
When should the end of the file be checked?
A. When opening the file.
B. When writing to the file.
C. When reading from the file.
D. When closing the file. - answerC. When reading from the file.
The text file scores.txt contains some integer numbers. It has been opened for reading
using the file pointer ptr.
Which statement will read the first number from the file into the variable score?
Assume: int score;
A. fscanf (ptr, "%d", score);
B. fscanf (ptr, "%d", &score);
C. fscanf ("%d", &score);
D. fscanf (ptr, &score); - answerB. fscanf (ptr, "%d", &score);
To work with a text file, which one of the following declarations is required?
, A. FILE ptr;
B. FILE * ptr;
C. File * ptr;
D. file * ptr; - answerB. FILE * ptr;
What does the function feof() return when the end of the file is reached?
A. it returns true (which is 1)
B. it returns the number of lines in the file.
C. It returns false (which is 0)
D. it returns -1 - answerA. it returns true (which is 1)
Assume the following declaration:
int num;
int * ptr;
Which statement will make the pointer point to variable num?
A. ptr = num;
B. ptr = #
C. ptr -> num;
D. ptr = # - answerD. ptr = #
Assume that the input file data.txt has been opened for reading using the file pointer
fptr.. The file contains several whole numbers:
34
55
90
22
100
16
Which of the following will read the third value into variable number?
Assume: int number;