Write a C/C++ program to count the total number of alphabet-, numeric- or special characters in a string by reading each character until a newline character is reached. The string is entered by the user. Square bracket notation for array access is allowed, i.e. array[i]. See the screenshot below (Figure 2.1) for example output. Hint: A direct comparison of two characters will compare the related ASCII values (see Table 2.1 below).

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter3: Data Representation
Section: Chapter Questions
Problem 4PE
icon
Related questions
Question

Write a C/C++ program to count the total number of
alphabet-, numeric- or special characters in a string
by reading each character until a newline character
is reached. The string is entered by the user.
Square bracket notation for array access is allowed, i.e. array[i].


See the screenshot below (Figure 2.1) for example
output.


Hint: A direct comparison of two characters will
compare the related ASCII values (see Table 2.1
below).

ASCII-Tabel / ASCII Table
112 P
a 113 | q
b 114
c 115 | s
T 100 | d 116 | t
U 101 | e 117 | u
54 6 70 F 86 v 102 f 118 | v
7 71 G|87 w 103 g| 119
56 8 72 H 88 x 104 h 120 x
57 9 73 | I 89 Y 105 | i 121 | y
z 106 |j 122
[ 107 k| 123 | {
60 < 76 L 92 \ 108 | 1 124 ||
=| 77 M| 93 | 1| 109 | m| 125 | }
110 n 126
47 |7 | 63 ? 79 0 95 - 111 0| 127 DEL
NUL 16 | DLE
32
48 0 64 | @ 80 | P| 96
49 1 65 | A 81 | Q| 97
50 2 66 B 82 R 98
51 | 3 67 | c 83 | s 99
52 4 68 | D 84
53 5 69 E 85
SP
SOH 17
DC1
STX 18 | DC2
3
2
34
ETX| 19 | DC3
EOT | 20 | DC4
ENQ 21
6.
35 #
4
36 $
NAK 37 %
АCK | 22
SYN
38
BEL | 23 | ETB
39
55
8
BS
24
CAN
40
9
HT
25
EM
41 )
10 LF
11 VT
26
SUB
42
58
74
90
27
ESC
43
59
75 K
91
12 FF
13
28 FS
44
45
29 GS
14 so 30 | RS
31 US
CR
61
46
94
62 > 78 N
15 SI
Tabel 2.1 / Table 2.1
O X
Enter any string : "P3ter p|cked @ p&ck of pickled pepper5"
Alphabets = 27
Digits = 2
Special characters = 11
Process returned 0 (@xe)
Press any key to continue.
execution time: 149.539 s
Figuur 2.1 / Figure 2.1
: de -- * + - L:N
m3mm mm m m T
Transcribed Image Text:ASCII-Tabel / ASCII Table 112 P a 113 | q b 114 c 115 | s T 100 | d 116 | t U 101 | e 117 | u 54 6 70 F 86 v 102 f 118 | v 7 71 G|87 w 103 g| 119 56 8 72 H 88 x 104 h 120 x 57 9 73 | I 89 Y 105 | i 121 | y z 106 |j 122 [ 107 k| 123 | { 60 < 76 L 92 \ 108 | 1 124 || =| 77 M| 93 | 1| 109 | m| 125 | } 110 n 126 47 |7 | 63 ? 79 0 95 - 111 0| 127 DEL NUL 16 | DLE 32 48 0 64 | @ 80 | P| 96 49 1 65 | A 81 | Q| 97 50 2 66 B 82 R 98 51 | 3 67 | c 83 | s 99 52 4 68 | D 84 53 5 69 E 85 SP SOH 17 DC1 STX 18 | DC2 3 2 34 ETX| 19 | DC3 EOT | 20 | DC4 ENQ 21 6. 35 # 4 36 $ NAK 37 % АCK | 22 SYN 38 BEL | 23 | ETB 39 55 8 BS 24 CAN 40 9 HT 25 EM 41 ) 10 LF 11 VT 26 SUB 42 58 74 90 27 ESC 43 59 75 K 91 12 FF 13 28 FS 44 45 29 GS 14 so 30 | RS 31 US CR 61 46 94 62 > 78 N 15 SI Tabel 2.1 / Table 2.1 O X Enter any string : "P3ter p|cked @ p&ck of pickled pepper5" Alphabets = 27 Digits = 2 Special characters = 11 Process returned 0 (@xe) Press any key to continue. execution time: 149.539 s Figuur 2.1 / Figure 2.1 : de -- * + - L:N m3mm mm m m T
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning