Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
13.6.1. C++ Example
This section
Practice test
11 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
4 cards from this lesson. Good the night before a test.
Try these first
- 1.
What class do you use to write to a binary file in C++?
Hint
Think about the file output stream.
- 2.
Which method do you call to write data to a file?
Hint
Look for the function related to outputting data.
- 3.
What is the purpose of the
ios::binarymode in C++ file handling?- To read text data
- To handle binary data
- To create new files
Hint
Think about what type of data you are working with.
- 4.
True or False: The
write()method requires the data to be in a string format.- True
- False
Hint
Consider what types of variables can be written directly.
- 5.
Write a C++ program that reads integers from a binary file and outputs their sum.
Hint
Think about how you'd read integers just like you wrote them.
- 6.
Create a binary file with five random integers in C++, then read the integers and display them to the console.
Hint
Focus on random number generation and binary reading processes.
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
3 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
2 more questions available
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting