Computer Science Quiz 5

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/221

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

222 Terms

1
New cards

fopen

The function used to open a file and return a FILE pointer for that file is .

2
New cards

NULL

When a file fails to open, fopen returns or evaluates as .

3
New cards

e

The format specifier to display floating point numbers in scientific notation is the percent sign followed by the letter: .

4
New cards

f

The format specifier that always shows the decimal point to display floating point numbers is the percent sign followed by the letter: .

5
New cards

c-string, character

"\n" is a and '\n' is a .

6
New cards

%.3f

Write the format specifier used to change the number of decimal places displayed in a floating point number to 3 decimal places.

7
New cards

getc, fgetc, and getchar

Which functions read one character even if that character is a blank space?

8
New cards

g

The format specifier to display floating point numbers in the shortest notation is the percent sign followed by the letter: .

9
New cards

fclose

When you are finished using a file you should close the file using the function .

10
New cards

fgets

is the safe function used to get a restricted length c-string from a file or the keyboard.

11
New cards

NULL

The special character used to mark the end of a C- string is called the character.

12
New cards

character

All data is input and output as data.

13
New cards

EOF

scanf, fscanf, and sscanf return .

14
New cards

C. displays a + in front of positive numbers.

  • is a format specifier flag that
15
New cards
16
New cards

A. displays a + in front of all numbers.

17
New cards

B. can be used to find the absolute value of an integer.

18
New cards

C. displays a + in front of positive numbers.

19
New cards

D. all of the above

20
New cards

A. prompting the file to ask for data

Which of the following is not used when using files for input and output?

21
New cards
22
New cards

A. prompting the file to ask for data

23
New cards

B. closing the file

24
New cards

C. ensuring that the file opened

25
New cards

D. opening the file

26
New cards

E. A and C

Which of the following function declarations will correctly pass a FILE pointer to the function?

27
New cards
28
New cards

A. void display(FILE* out);

29
New cards

B. void display(out* FILE);

30
New cards

C. FILE* display(FILE* out);

31
New cards

D. void display(FILE out);

32
New cards

E. A and C

33
New cards

C. must know the kind of data in the file.

In order to read data from a file correctly you

34
New cards
35
New cards

A. do not need to know the kind of data in the file.

36
New cards

B. should prompt the user for the data you are looking for.

37
New cards

C. must know the kind of data in the file.

38
New cards

D. A and C

39
New cards

A. when opening the file

When is the external name of the file used in the program?

40
New cards
41
New cards

A. when opening the file

42
New cards

B. only when reading from the file

43
New cards

C. never

44
New cards

D. any time you read or write to the file

45
New cards

A. isdigit

Which function returns true if the character argument is a digit?

46
New cards
47
New cards

A. isdigit

48
New cards

B. isalpha

49
New cards

C. islower

50
New cards

D. isspace

51
New cards

A. 10

If the user types in the characters '1' and '0', and your program reads them into an integer variable with no spaces in between using scanf and %d, what is the value stored into that integer?

52
New cards
53
New cards

A. 10

54
New cards

B. 1

55
New cards

C. 0

56
New cards

D. none of the above

57
New cards

A. one character value.

The fgetc function reads

58
New cards
59
New cards

A. one character value.

60
New cards

B. one double value.

61
New cards

C. one integer value.

62
New cards

D. one float value.

63
New cards

A. display an error message and take some suitable action such as exit.

If a file did not open correctly, you should

64
New cards
65
New cards

A. display an error message and take some suitable action such as exit.

66
New cards

B. continue on anyway.

67
New cards

C. exit the program immediately.

68
New cards

D. Display an error message and continue on.

69
New cards

A. if(inFile == NULL)

Which of the following is the correct way to determine if a file referred to in the FILE pointer named inFile failed to open correctly after calling fopen?

70
New cards
71
New cards

A. if(inFile == NULL)

72
New cards

B. if(inFile != NULL)

73
New cards

C. if(fail(inFILE))

74
New cards

D. if(inFile is not open)

75
New cards

C. display the integer x in at least width characters.

The command fprintf(outFile, "%*d",width, x); is used to

76
New cards
77
New cards

A. Use an entire line to output x.

78
New cards

B. change the number of characters in the output.

79
New cards

C. display the integer x in at least width characters.

80
New cards

D. set the filename of outFile to width characters.

81
New cards

C. one character value.

The fputc function outputs

82
New cards
83
New cards

A. one float value.

84
New cards

B. one double value.

85
New cards

C. one character value.

86
New cards

D. one integer value.

87
New cards

C. char filename[21];

To open a file with a user supplied name, you would need to store the name in a variable. If the file name was to have no more than 20 characters in it, which would be an appropriate declaration of the file name variable?

88
New cards
89
New cards

A. char filename[20];

90
New cards

B. char filename;

91
New cards

C. char filename[21];

92
New cards

D. char filename(20);

93
New cards

B. fp = fopen("project.txt", "a");

To open an output file and add to the end of the data already in the file using the FILE pointer fp you would write .

94
New cards
95
New cards

A. fp = fopen("project.txt",APPEND);

96
New cards

B. fp = fopen("project.txt", "a");

97
New cards

C. append(fp, "project.txt");

98
New cards

D. *fp = fopen("project.txt", "a");

99
New cards

B. inFile = fopen(filename, "r");

If the name of the input file was in a c-string variable named filename, which of the following is the correct way to open the file for reading and associate it with the FILE object referred to by the FILE pointer named inFile?

100
New cards