COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
charfunc.cpp File Reference
#include <iostream>
#include <cctype>
Include dependency graph for charfunc.cpp:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( void )

Definition at line 6 of file charfunc.cpp.

7{
8 char a;
9
10 a = '7';
11 cout << a << (isdigit(a) ? " is " : " is not ") << "a digit" << endl;
12 a = '$';
13 cout << a << (isdigit(a) ? " is " : " is not ") << "a digit" << endl;
14
15 a = 'B';
16 cout << a << (isalpha(a) ? " is " : " is not ") << "a letter" << endl;
17 a = 'b';
18 cout << a << (isalpha(a) ? " is " : " is not ") << "a letter" << endl;
19 a = '4';
20 cout << a << (isalpha(a) ? " is " : " is not ") << "a letter" << endl;
21
22 a = 'Z';
23 cout << a << (islower(a) ? " is " : " is not ") << "a lowercase letter" << endl;
24 a = 'z';
25 cout << a << (islower(a) ? " is " : " is not ") << "a lowercase letter" << endl;
26 a = '5';
27 cout << a << (islower(a) ? " is " : " is not ") << "a lowercase letter" << endl;
28
29 a = 'M';
30 cout << a << (isupper(a) ? " is " : " is not ") << "an uppercase letter" << endl;
31 a = 'm';
32 cout << a << (isupper(a) ? " is " : " is not ") << "an uppercase letter" << endl;
33 a = '#';
34 cout << a << (isupper(a) ? " is " : " is not ") << "an uppercase letter" << endl;
35
36 return 0;
37}