-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path13_own_library.c
71 lines (68 loc) · 1.64 KB
/
13_own_library.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/***************************************************************************************
NAME : Karthikeyan.V
DATE : 17.06.2021
DESCRIPTION : Implement your own c-type library (any four).
OUTPUT :./a.out
ENTER THE CHARACTER: A
SELECT AN OPTION:
1.isalpha
2.isalnum
3.isascii
4.islower
ENTER YOUR CHOICE: 1
THE CHARACTER 'A' is an alpha character
DO YOU WANT TO CONTINUE(y/Y):n
***************************************************************************************/
#include<stdio.h>
int alpha(char ch);
int alnum(char ch);
int ascii(char ch);
int lower(char ch);
int main()
{
char ch, choice;
int operation;
do
{
printf("ENTER THE CHARACTER: " );
scanf(" %c",&ch);
printf("SELECT AN OPTION:\n1.isalpha\n2.isalnum\n3.isascii\n4.islower\nENTER YOUR CHOICE: ");
scanf("%d",&operation);
printf("THE CHARACTER '%c' is ",ch);
switch(operation)
{
case 1:
alpha(ch)?printf("an alpha character"):printf("not an alpha character");
break;
case 2:
alnum(ch)?printf("an alnum character"):printf("not an alnum character");
break;
case 3:
ascii(ch)?printf("an ascii character"):printf("not an ascii character");
break;
case 4:
lower(ch)?printf("a lower character"):printf("not a lower character");
break;
default:
printf("INVALID CHOICE OF OPERATION");
}
printf("\nDO YOU WANT TO CONTINUE(y/Y):");
scanf(" %c",&choice);
}while(choice=='y' || choice=='Y');
}
int alpha(char ch)
{
return ( ch >= 65 && ch<=90 || ch >= 97 && ch <= 122 );
}
int alnum(char ch)
{
return ( alpha(ch) || (ch>=48 && ch<=57) );
}
int ascii(char ch)
{
return ( ch>=0 && ch<=127 );
}
int lower(char ch)
{
return ( ch >= 65 && ch<=90 );
}