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

Nkuzi Olu

Gee ntị na nkuzi a na ngwa

Maapụ uche

E seela isiokwu a ka ị hụ otu echiche si ejikọta.

Mepee maapụ uche na ngwa

Kaadị ncheta

Omume ncheta ngwa ngwa n'ihe a na-anwale n'isiokwu a.

Mee omume kaadị ndị a na ngwa

Akwụkwọ Ọmụmụ

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.

Ndetu Nkuzi Zuru Ezu di na Ngwa Green Bridge

Nweta ngwa Green Bridge CBT na ekwenti gi ma o bu kompiuta maka ulo akwukwo IGCSE zuru oke: akwukwo ule ndi gara aga, usoro nyocha, eserese uche, kaadi omumu na nkuzi olu.

Akwụkwọ ndụmọdụ zuru oke nwere eserese
Onye inyeaka mmụta AI
Ule nnwale nwere oge a na-ahazi ozugbo i mechara
Ọ dị na Android, Windows, macOS, na Linux Ngwa iOS na-abia n'oge na-adighi anya

Nnyocha Ọmụmụ

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

Rue ajuju ndi a n'ime ngwa ahu

Rue ajuju ndi a n'ime ngwa ahu

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.

Budata Ngwa Ahụ Na Google Playstore

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

Green Bridge CBT Mobile App
Onye Enyemaka Nkata AI Nke Ọmụmụ Ihe Ahaziri Maka Gị
Ajụjụ ule IGCSE, JAMB, WAEC na NECO karịrị 200,000
Ihe karịrị 1200 Nkọwa Nkuzi
Nkwado Na-enweghị Ịntanetị - Mụọ Ihe Mgbe Ọ Bụla, Ebe Ọ Bụla
Jadawalin Gada Kore
Akọkọ akọle iwe & Ibeere agbara
Sọfụma Ọrụ Gi & Ọganihu Gi
Nkọwa Miri Emi Maka Ọmụmụ Ihe Zuru Ezu