Computer Science (9-1) - 0984 CIE

File Handling

Gbogbo ọrọ náà

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.

Ebumnobi

  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ọmọ Ojú-ẹ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.

Ọ dị na ngwa Green Bridge

Budata ngwa Green Bridge CBT na ekwentị maọbụ kọmputa gị iji nweta akwụkwọ ndụmọdụ zuru oke, ajụjụ mmụta, na ndị ọzọ.

Akwụkwọ ndụmọdụ zuru oke nwere eserese
Onye inyeaka mmụta AI
Mụọ n'ụzọ na-enweghị ịntaneti, oge ọbụla, ebe ọbụla
Ọ dị na Android, Windows, macOS, na Linux

Ayẹwo Ẹkọ

Ekele diri gi maka imecha ihe karịrị na File Handling. Ugbu a na ị na-enyochakwa isi echiche na echiche ndị dị mkpa, ọ bụ oge iji nwalee ihe ị ma. Ngwa a na-enye ụdị ajụjụ ọmụmụ dị iche iche emebere iji kwado nghọta gị wee nyere gị aka ịmata otú ị ghọtara ihe ndị a kụziri.

Ị ga-ahụ ngwakọta nke ụdị ajụjụ dị iche iche, gụnyere ajụjụ chọrọ ịhọrọ otu n’ime ọtụtụ azịza, ajụjụ chọrọ mkpirisi azịza, na ajụjụ ede ede. A na-arụpụta ajụjụ ọ bụla nke ọma iji nwalee akụkụ dị iche iche nke ihe ọmụma gị na nkà nke ịtụgharị uche.

Jiri akụkụ a nke nyocha ka ohere iji kụziere ihe ị matara banyere isiokwu ahụ ma chọpụta ebe ọ bụla ị nwere ike ịchọ ọmụmụ ihe ọzọ. Ekwela ka nsogbu ọ bụla ị na-eche ihu mee ka ị daa mba; kama, lee ha anya dị ka ohere maka ịzụlite onwe gị na imeziwanye.

  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

Ọ dị na ngwa Green Bridge

Budata ngwa Green Bridge CBT na ekwentị maọbụ kọmputa gị iji nweta akwụkwọ ndụmọdụ zuru oke, ajụjụ mmụta, na ndị ọzọ.

Akwụkwọ ndụmọdụ zuru oke nwere eserese
Onye inyeaka mmụta AI
Mụọ n'ụzọ na-enweghị ịntaneti, oge ọbụla, ebe ọbụla
Ọ dị na Android, Windows, macOS, na Linux

Ọ dị na ngwa Green Bridge

Budata ngwa Green Bridge CBT na ekwentị maọbụ kọmputa gị iji nweta akwụkwọ ndụmọdụ zuru oke, ajụjụ mmụta, na ndị ọzọ.

Akwụkwọ ndụmọdụ zuru oke nwere eserese
Onye inyeaka mmụta AI
Mụọ n'ụzọ na-enweghị ịntaneti, oge ọbụla, ebe ọbụla
Ọ dị na Android, Windows, macOS, na Linux

Meecha Ajụjụ Ule Ọmarịcha

Ị chọrọ ime ajụjụ ule ọmarịcha gbasara File Handling? Budata ngwa Green Bridge CBT iji nweta ajụjụ ule ọmarịcha na nyocha zuru ezu gbasara isiokwu a.

Dawunlodi Ẹpp naa lori Google Playstore.

Ihe nile ichoro iji nwee ihe ịga nke ọma na JAMB, WAEC & NECO.

Green Bridge CBT Mobile App
Personalized AI Ẹ̀kọ́ Ọ̀rọ̀ Alábàápàdé.
Egbò ọdúnrún JAMB, WAEC & NECO Ajùmọ̀ṣe ìbéèrè ti kọjá.
Ihe karịrị 1200 Nkọwa Nkuzi
Tallafi Ba Tare da Layin Intanet Ba - Koyi Duk Lokaci, Ko'ina
Jadawalin Gada Kore
Akọkọ akọle iwe & Ibeere agbara
Sọfụma Ọrụ Gi & Ọganihu Gi
Ìtọ́jú Ìtúmọ̀ fún Ẹ̀kọ́ Alábáyọrí.