Write a function, ReadFile(), that reads the content of the provided text file “numbers.txt” (see Appendix A) and stores it in an array. The function receives as parameter a pointer to a character array where the content of the text file should be stored. The number of lines that was read from the text file must be returned to the calling statement.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Question 1.1
Write a function, ReadFile(), that reads the content
of the provided text file “numbers.txt” (see
Appendix A) and stores it in an array. The function
receives as parameter a pointer to a character
array where the content of the text file should be
stored. The number of lines that was read from the
text file must be returned to the calling statement.


Question 1.2
Write a function, analyseStNumber(), which
receives a number as parameter and determines
whether the number is a valid student number or
not. Use the following validity test to determine the
validity of a student number:
Student number: 20570856
sum = (2*8)+(0*7)+(5*6)+(7*5)+(0*4)+(8*3)+(5*2)+(6*1)
result = sum%11
If the result equals 0, the number is a valid student
number; if the result is not equal to 0, the number
is an invalid student number.
The function MUST use a loop to analyse the
number by looking at each individual digit in the
number.
The function returns a 1 (valid) or 0 (invalid) to the
calling statement.
Hint: Repeatedly use integer division (/) with 10
and the remainder after integer division (%) with 10
to isolate the individual digits of the number

Question 1.3
Write a function, WriteFile(), which receives a
student number and status of the student number
as arguments.
If the student number is valid, i.e. status = 1, the
number must be written to an output file,
ValidNumbers.txt. If the student number is invalid,
the number must be written to an output file,
InvalidNumbers.txt (see Appendix A).
The number and status are displayed on the screen
in both cases.
The function returns no value to the calling
statement.


Question 1.4
The above functions (ReadFile(),
analyseStNumber(), and WriteFile()) must now be
implemented in the main program (main()) in the
following order with a fitting message as in
Figure 3:
1. Create an array of type integer and make
provision for a maximum of 100 elements.
2. Read the contents of the text file “numbers.txt”
to the array with ReadFile().
3. Call the analyseStNumber() function to test
each of the numbers in the array for validity.
4. Call the WriteFile() function to write each of the
numbers to the correct output file.

12845078
Iwalld
PITCANT
12 45678
7654121
70012400
29813360
B0489059
30350069
30530679
28863496
87873909
30989698
30256607
30048117
30598303
29952239
29982995
30228484
29092248
27469352
28615425
27154033
29897890
30031338
30165970
30954177
30907276
30804507
30007674
30017416
30038227
30238072
28881389
45688555
INValid
INValid
INValid
Valid
Valid
Valid
Valid
Valid
INvalid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
Valid
INvalid
Figuur 3/ Figure 3
20201122 231
ing
IMG 20201122 2304
IMG 20201122 2304
ing
Transcribed Image Text:12845078 Iwalld PITCANT 12 45678 7654121 70012400 29813360 B0489059 30350069 30530679 28863496 87873909 30989698 30256607 30048117 30598303 29952239 29982995 30228484 29092248 27469352 28615425 27154033 29897890 30031338 30165970 30954177 30907276 30804507 30007674 30017416 30038227 30238072 28881389 45688555 INValid INValid INValid Valid Valid Valid Valid Valid INvalid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid Valid INvalid Figuur 3/ Figure 3 20201122 231 ing IMG 20201122 2304 IMG 20201122 2304 ing
A Read aloud Draw
V Highlight
ValldNumbers.txt (Afvoer/Output)
InvalidNumbers.txt (Afvoer/Output)
20570856
12345678
87654321
29813360
30489059
12345678
30350069
87654321
30530679
28863496
30989698
79012400
87873909
45688555
30256607
30048117
30598303
29952239
29982995
30228484
29092248
27469352
28615425
27154033
29897890
Transcribed Image Text:A Read aloud Draw V Highlight ValldNumbers.txt (Afvoer/Output) InvalidNumbers.txt (Afvoer/Output) 20570856 12345678 87654321 29813360 30489059 12345678 30350069 87654321 30530679 28863496 30989698 79012400 87873909 45688555 30256607 30048117 30598303 29952239 29982995 30228484 29092248 27469352 28615425 27154033 29897890
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education