Computer Science (9-1) - 0984 CIE

File Handling

Akopọ

When a program stops, everything it was holding in memory vanishes. So how does a game remember your progress, or a program keep a high score between sessions? The answer is file handling: writing data out to a file that survives after the program ends, and reading it back when the program runs again.

In this lesson you will learn why programs store data in files, then learn the standard pseudocode for opening, reading from, writing to and closing a file. You will trace small routines that save and reload data so you can write file-handling code with confidence in the exam.

Awọn Afojusun

  1. 1 Understand the purpose of storing data in a file to be used by a program
  2. 2 Open, close and use a file for reading and writing

Akọ̀wé Ẹ̀kọ́

Data held in variables lives only in memory; close the program and it is gone. File handling is the storage and access of data in a file so it can be used again later. Without it a program could never remember anything between runs. Saved games, high-score tables, settings and records all rely on it, and 0478 expects you to read from and write to a text file using the standard pseudocode.

O wa lori ohun elo Green Bridge

Gba ohun elo Green Bridge CBT sori foonu tabi kọmputa rẹ lati ri awọn akọsilẹ ẹkọ ni kikun, awọn ibeere adaṣe, ati diẹ sii.

Awọn akọsilẹ ẹkọ ni kikun pẹlu awọn aworan apejuwe
Oluranlọwọ ẹkọ ti AI ṣe agbara rẹ
Kọ ẹkọ laisi intanẹẹti, nigbakugba, nibikibi
O wa lori Android, Windows, macOS, ati Linux

Ìdánwò Ẹ̀kọ́

Oriire fun ipari ẹkọ lori File Handling. Ni bayi ti o ti ṣawari naa awọn imọran bọtini ati awọn imọran, o to akoko lati fi imọ rẹ si idanwo. Ẹka yii nfunni ni ọpọlọpọ awọn adaṣe awọn ibeere ti a ṣe lati fun oye rẹ lokun ati ṣe iranlọwọ fun ọ lati ṣe iwọn oye ohun elo naa.

Iwọ yoo pade adalu awọn iru ibeere, pẹlu awọn ibeere olumulo pupọ, awọn ibeere idahun kukuru, ati awọn ibeere iwe kikọ. Gbogbo ibeere kọọkan ni a ṣe pẹlu iṣaro lati ṣe ayẹwo awọn ẹya oriṣiriṣi ti imọ rẹ ati awọn ogbon ironu pataki.

Lo ise abala yii gege bi anfaani lati mu oye re lori koko-ọrọ naa lagbara ati lati ṣe idanimọ eyikeyi agbegbe ti o le nilo afikun ikẹkọ. Maṣe jẹ ki awọn italaya eyikeyi ti o ba pade da ọ lójú; dipo, wo wọn gẹgẹ bi awọn anfaani fun idagbasoke ati ilọsiwaju.

  1. Why does a program store data in a file rather than only in a variable? A. files run faster than variables B. data in a variable is lost when the program ends, but a file keeps it C. variables cannot hold numbers D. files do not need to be opened Answer: B
  2. Which pseudocode keyword opens a file ready to read from it? A. WRITEFILE B. CLOSEFILE C. OPENFILE name FOR READ D. EOF Answer: C
  3. What does opening a file FOR WRITE do to data already in the file? A. appends to the end B. leaves it unchanged C. overwrites it D. encrypts it Answer: C
  4. Which statement saves changes and frees a file after use? A. OPENFILE B. READFILE C. WRITEFILE D. CLOSEFILE Answer: D
  5. What does EOF(name) return when the end of the file is reached? A. the last line B. FALSE C. TRUE D. the filename Answer: C

O wa lori ohun elo Green Bridge

Gba ohun elo Green Bridge CBT sori foonu tabi kọmputa rẹ lati ri awọn akọsilẹ ẹkọ ni kikun, awọn ibeere adaṣe, ati diẹ sii.

Awọn akọsilẹ ẹkọ ni kikun pẹlu awọn aworan apejuwe
Oluranlọwọ ẹkọ ti AI ṣe agbara rẹ
Kọ ẹkọ laisi intanẹẹti, nigbakugba, nibikibi
O wa lori Android, Windows, macOS, ati Linux

O wa lori ohun elo Green Bridge

Gba ohun elo Green Bridge CBT sori foonu tabi kọmputa rẹ lati ri awọn akọsilẹ ẹkọ ni kikun, awọn ibeere adaṣe, ati diẹ sii.

Awọn akọsilẹ ẹkọ ni kikun pẹlu awọn aworan apejuwe
Oluranlọwọ ẹkọ ti AI ṣe agbara rẹ
Kọ ẹkọ laisi intanẹẹti, nigbakugba, nibikibi
O wa lori Android, Windows, macOS, ati Linux

Ṣe Adaṣe Awọn Ibeere Idanwo Adaṣe

Ṣe o fẹ ṣe adaṣe awọn ibeere idanwo adaṣe nipa File Handling? Ṣe igbasilẹ ohun elo Green Bridge CBT lati wọle si awọn ibeere idanwo adaṣe ati awọn ayẹwo adaṣe kikun fun koko-ọrọ yii.

Ṣe igbasilẹ ohun elo naa lori Google Playstore

Gbogbo ohun ti o nilo lati ṣe dara julọ ninu JAMB, WAEC ati NECO.

Green Bridge CBT Mobile App
Asiko ẹkọ AI ti ara ẹni Chat Assistant
Ẹgbẹẹgbẹrun Awọn Ibeere Atijọ JAMB, WAEC & NECO
Fiwọn 1200 Awọn akọsilẹ Ẹkọ ju.
Atilẹyin Aisinipo - Kọ ẹkọ Nigbakugba, Nibi gbogbo
Tẹ̀dí Green Bridge
Àkójọpọ̀ Ìtàn Lítíréṣọ̀ & Ìbéèrè Tó Lè Dáyéé ṣẹ́lẹ̀
Tẹle iṣẹ ṣiṣe rẹ ati ilọsiwaju rẹ.
Àlàyé tí ó jinlẹ̀ fún ìmòye tó jinlẹ̀.