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