Topics: Files, Pointers, Functions and Arrays Task 1 Create a C++ project called PntIDNumbers. 1.1 Declare an array called arrIDs that will be able to hold 200 elements. Declare a pointer for the array. 1.2 Open Notepad and create a text file called idnumbers.txt. Make sure that the text file is saved in the same folder as the project. O idnumbers - Notepad File Edit Format View Help 7803045678087 8904050876092 9002017896054 _9408072345087 8703083456098 7812120867087 0108068675087 1012239687087 es01090675e86 _9911220768082 1.3 Write a method called readFromFile that will receive a pointer to the address of the first element of the arrIDs array. Read a number of idnumbers from a text file called 1 idnumbers.txt into the array. Display a message indicating that data is being read from the file. Return the number of elements saved in the arrIDs array. о. 1 Example: Reading from file... 1.3 Write a function called displayIDnumbers that will receive the pointer of the first element of the arrIDs array and the number of elements in the array. Display the list of IDnumbers. Example: List of IDnumbers 7803045678087 _8904050876092 _9002017896054 9408072345087 8703083456098 _7812120867887 0108068675087 _1012239687087 _0801090675e86 _99112207680e82 1.4 Write a function called displayYearsBorn that will receive the pointer of the first element of the arrIDs array and the number of elements in the array. Write code to display the year that each person was born. NOTE: No. 2 • No square brackets are allowed to be Used in the solution

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
Help with C++ programming
Topics: Files, Pointers, Functions and Arrays
Task 1
Create a C++ project called PntIDNumbers.
1.1 Declare an array called arrIDs that will be able
to hold 200 elements. Declare a pointer for the
array.
1.2 Open Notepad and create a text file called
idnumbers.txt. Make sure that the text file is
saved in the same folder as the project.
O idnumbers - Notepad
File Edit Format View Help
7803045678087
8904050876092
9002017896054
9408072345087
8703083456e98
7812120867087
_0108068675087
_1012239687087
0801090675086
_9911220768082
1.3 Write a method called readFromFile that will
receive a pointer to the address of the first
element of the arrIDs array. Read a number of
idnumbers from a text file called
idnumbers.txt into the array. Display a
message indicating that data is being read
from the file. Return the number of elements
saved in the arrIDs array.
Example:
No. 1
Reading from file...
1.3 Write a function called displayIDnumbers that
will receive the pointer of the first element of
the arrIDs array and the number of elements
in the array.
Display the list of IDnumbers.
Example:
List of IDnumbers
7803045678087
8904050876092
9002017896054
9408072345087
8703083456098
_7812120867087
_0108068675087
1012239687087
_0801090675086
99112207680e82
1.4 Write a function called displayYearsBorn that
will receive the pointer of the first element of
the arrIDs array and the number of elements
in the array.
Write code to display the year that each
person was born.
NOTE:
No. 2
• No square brackets are allowed to be
used in the solution.
Transcribed Image Text:Topics: Files, Pointers, Functions and Arrays Task 1 Create a C++ project called PntIDNumbers. 1.1 Declare an array called arrIDs that will be able to hold 200 elements. Declare a pointer for the array. 1.2 Open Notepad and create a text file called idnumbers.txt. Make sure that the text file is saved in the same folder as the project. O idnumbers - Notepad File Edit Format View Help 7803045678087 8904050876092 9002017896054 9408072345087 8703083456e98 7812120867087 _0108068675087 _1012239687087 0801090675086 _9911220768082 1.3 Write a method called readFromFile that will receive a pointer to the address of the first element of the arrIDs array. Read a number of idnumbers from a text file called idnumbers.txt into the array. Display a message indicating that data is being read from the file. Return the number of elements saved in the arrIDs array. Example: No. 1 Reading from file... 1.3 Write a function called displayIDnumbers that will receive the pointer of the first element of the arrIDs array and the number of elements in the array. Display the list of IDnumbers. Example: List of IDnumbers 7803045678087 8904050876092 9002017896054 9408072345087 8703083456098 _7812120867087 _0108068675087 1012239687087 _0801090675086 99112207680e82 1.4 Write a function called displayYearsBorn that will receive the pointer of the first element of the arrIDs array and the number of elements in the array. Write code to display the year that each person was born. NOTE: No. 2 • No square brackets are allowed to be used in the solution.
NOTE:
• No square brackets are allowed to be
used in the solution.
• No prewritten functions are allowed to be
used in the solution.
Example of output:
3/6
List of years born
Year born: 1978
Year born: 1989
Year born: 1990
Year born: 1994
Year born: 1987
Year born: 1978
Year born: 2001
Year born: 2010
Year born: 2008
No. 3
Year born: 1999
How to convert a single character in a string into
an integer:
You can utlize the fact that the character encodings for digits are all in order trom 48 (for 0) to 57
(lor ). This holds Yue for ASCII, UTF-x and practically all other encodings (see comments below for
more on this)
Therefore the integer value for any digt is the digt minus O (or 48)
char 'i
int e's Iis nw equel to 1, not 1
is synonymous to
char e
int I-- 48 1 is now equal to 1, not '1
ASCII table
AS Ch ASai Ch ASa Ch ASCI Char A Car AseI Char caChar ASOI
Char
Chur
Chur ASOI
OMUL 15
DIE 32 SP
64 e tes
SP
48
49
1.
SOH 17
33
97
113
2 R
2 STA 18
3
4
34
50
66
134
35
51
67
ETX
TEOT 20 DC4 35 S D M
EMO 21 NAK 2
19
DC3
115
68
D
100
37
53
101
117
ACE 22 SENa
SYN
38
REL 23 TR 4
ETB
54
6
20
86
102
2
138
23
33
55
71
103
129
24
CAN
40
56
72
104
120
HT
25
EM
41
57
73
105
121
10 v 24 SUB 42
25
27
74
106
122
ESC
41
75
107
k
123
12 lu u
FS
21
44
134
1a a 6s
29
77
CR
GS
45-
109
125
14 Tenam Is
so
46
94
110
us te
47
tuu la 27 DEL
111 127
15
31
79
95
|
Hint:
for (int k- 0 k< *pCounter: k++)
if ((* (PIDS + k) ))
digitl = (* (PIDS + k + 1) -'0')* 10
digit2 = (* (pIDs + k + 2) -'0'):
year- digiti + digit2;
1.5 Write a function called displayMonthsBorn
that will receive the pointer of the first element
of the arrIDs array and the number of
elements in the array.
Write code to display the months that each
person was born.
NOTE:
• No square brackets are allowed to be
used in the solution.
• No prewritten functions are allowed to be
used in the solution.
Example of output:
List of months born
Month born: 3
Month born: 4
Month born: 2
Month born: 8
Month born: 3
Month born: 12
Month born: 8
Month born: 12
Month born: 1
Month born: 11
No. 4
Transcribed Image Text:NOTE: • No square brackets are allowed to be used in the solution. • No prewritten functions are allowed to be used in the solution. Example of output: 3/6 List of years born Year born: 1978 Year born: 1989 Year born: 1990 Year born: 1994 Year born: 1987 Year born: 1978 Year born: 2001 Year born: 2010 Year born: 2008 No. 3 Year born: 1999 How to convert a single character in a string into an integer: You can utlize the fact that the character encodings for digits are all in order trom 48 (for 0) to 57 (lor ). This holds Yue for ASCII, UTF-x and practically all other encodings (see comments below for more on this) Therefore the integer value for any digt is the digt minus O (or 48) char 'i int e's Iis nw equel to 1, not 1 is synonymous to char e int I-- 48 1 is now equal to 1, not '1 ASCII table AS Ch ASai Ch ASa Ch ASCI Char A Car AseI Char caChar ASOI Char Chur Chur ASOI OMUL 15 DIE 32 SP 64 e tes SP 48 49 1. SOH 17 33 97 113 2 R 2 STA 18 3 4 34 50 66 134 35 51 67 ETX TEOT 20 DC4 35 S D M EMO 21 NAK 2 19 DC3 115 68 D 100 37 53 101 117 ACE 22 SENa SYN 38 REL 23 TR 4 ETB 54 6 20 86 102 2 138 23 33 55 71 103 129 24 CAN 40 56 72 104 120 HT 25 EM 41 57 73 105 121 10 v 24 SUB 42 25 27 74 106 122 ESC 41 75 107 k 123 12 lu u FS 21 44 134 1a a 6s 29 77 CR GS 45- 109 125 14 Tenam Is so 46 94 110 us te 47 tuu la 27 DEL 111 127 15 31 79 95 | Hint: for (int k- 0 k< *pCounter: k++) if ((* (PIDS + k) )) digitl = (* (PIDS + k + 1) -'0')* 10 digit2 = (* (pIDs + k + 2) -'0'): year- digiti + digit2; 1.5 Write a function called displayMonthsBorn that will receive the pointer of the first element of the arrIDs array and the number of elements in the array. Write code to display the months that each person was born. NOTE: • No square brackets are allowed to be used in the solution. • No prewritten functions are allowed to be used in the solution. Example of output: List of months born Month born: 3 Month born: 4 Month born: 2 Month born: 8 Month born: 3 Month born: 12 Month born: 8 Month born: 12 Month born: 1 Month born: 11 No. 4
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
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
  • SEE MORE 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